From the course: Code Clinic: C++
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Format JSON request
- [Instructor] The body of the request that I sent to the Geolocation API needs to be formatted in JSON that looks something like this. With a field for whether or not to consider the IP address and then possibly a few wifiAccessPoints with the macAddress and signalStrength. The C++ standard library does not include any built-in JSON parsers. Rather than building my own from scratch, I looked at json.org where there's an extensive list of available libraries that provide JSON support in various languages. Of the ones written for C and C++, they all have their own advantages and disadvantages and I'd encourage you to play around with a few different ones. For this challenge, I chose Dave Gamble's cJSON library because it has a simple interface and was super easy to incorporate into my program. It only requires a single c file and the corresponding header file. My function to build the JSON request packet starts at line…
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.