From the course: Exploring C Libraries
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Creating JSON output - C Tutorial
From the course: Exploring C Libraries
Creating JSON output
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Understanding XML2m 23s
-
(Locked)
Testing the libxml2 installation3m 10s
-
(Locked)
Accessing XML data3m 26s
-
(Locked)
Generating XML data3m 57s
-
(Locked)
Working with JSON2m 39s
-
(Locked)
Testing the json-c installation3m 17s
-
(Locked)
Accessing JSON data3m 10s
-
(Locked)
Reading JSON data3m 46s
-
(Locked)
Creating JSON output3m 35s
-
-
-
-
-