Once a JSON object is created, json-c functions are used to determine its data type and then specific functions are used to extract that data from the object, which is how JSON data is read in a C program. This video demonstrates how to extract data types and contents from JSON objects so that a C program can examine the JSON data.
- [Narrator] To read a specific value from JSON data, … you need to use the JSON-C library to create … a JSON object variable. … Next, you must know the element's name or key, … as well as the type of data stored. … This code searches the sample JSON data file, … named at line seven, looking for the key name, "lastName", … which is set at line eight. … The file is opened at line 13, with a JSON object variable … "jdata" holding the data. … Line 21 creates a JSON object for the named key, … which is saved in variable "objname", … the third argument in the function. … From this new object, the data type is determined … by the JSON object get type function, found at line 29. … Afterwards, a switch case structure is used … to output the type of data found. … I've already built and run the code, … so let's see what it does. … And the data type for last name, is a string. … To show the variety of data types in the sample document, … in this code, a while loop is found at line 25. … It processes all the entries at the top level, …
- 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.