DEV Community

Ashok Mohanakumar
Ashok Mohanakumar

Posted on

Make get request and parse JSON in C?

I'm trying to learn C and get comfortable with it. How do I make HTTP requests?
What do I do to handle JSON?

Top comments (10)

Collapse
 
hoelzro profile image
Rob Hoelz

Out of curiosity, what's your motivation for learning C? I think that trying something like making HTTP requests and parsing JSON is going to be very frustrating if you're just trying to learn, and depending on what you intend to use it for, may not be something you end up doing in C anyway!

Collapse
 
ashokcodes profile image
Ashok Mohanakumar

I am trying to build a service that makes post request to an API that provides IVR functionalities and handles the response and manages many things such as retries, call status, etc
Just wanted to try doing some http stuff with C

Collapse
 
hoelzro profile image
Rob Hoelz

Any particular reason you want to do this in C rather than a higher-level language (eg. running on an embedded device)? Or just as an exercise to learn C?

Collapse
 
snhilde profile image
Hilde N

I use CURL and cJSON for these issues.

You can see some examples for GET and POST requests in this parser program. You would be interested in get_weather() (and its two parser functions) and get_portfolio_value()/parse_portfolio_json() for GET requests and parsing the jsons and get_token() as an example of a POST request.

Hilde

Collapse
 
aghost7 profile image
Jonathan Boudreau

I've never tried it, but this framework looks interesting: kore.io/

Here's an example using yajl to parse JSON:

git.kore.io/kore/file/examples/jso...

Collapse
 
cosminpopescu14 profile image
Cosmin Popescu

Although it is not in plain C (ANSI C) check this out

github.com/nlohmann/json

Collapse
 
mrajarao76 profile image
Raja Rao

{
"piGroup":" ",
"nonSerializedScanData": [],
"serializedScanData": [],
"piType": "MINI",
"isLastUser": true,
"sessionId": ""
}

Collapse
 
ashokcodes profile image
Ashok Mohanakumar

Thanks a lot !!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.