Building new JSON data starts with creating JSON objects and adding them to each other. Different functions from the json-c library create objects and add them to each other, which is how JSON data is built within a C program. The JSON data created can be output as a string, or the string can be saved to a file just as any string is saved to a file in C.
- [Instructor] As with reading JSON data … in the JSON C library, creating JSON data … involves using a JSON object variable. … In this code, a new JSON object, jdata, … is created at line 11. … It's empty. … No other objects are added, still the object exists, … and it can be output which is what happens … at line 20. … The object is converted to a string … and it's output directly to the console. … Now I have already compiled and linked the code … so let's see what it does. … And there's the new object. … Not very helpful, but it was created. … In this update, a second JSON object is created. … The JSON object, jnewobj, is created at line 19, … assigned to the strong George Washington. … At this point, the code has two JSON objects independent … of each other, but at line 30, … the json_object_object_add function … adds the jnewobj string to the jdata object, … assigning it to a keyname, Name. … As before, this object is converted to a string, … and then output. … Let's see what it looks like. …
- Finding, installing, and linking libraries
- Accessing and generating XML data
- Working with JSON
- Working with the libcurl library
- Text programming
- Reading, writing, and manipulating JPEG images
- Working with PNG images
Skill Level Advanced
1. Setup and Configuration
2. Data Structures
3. Web Access
4. Text Programming
5. Computer Graphics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.