Questions tagged [cjson]

cJSON aims to be the dumbest possible parser that you can get your job done with. It's a single file of C, and a single header file.

cJSON aims to be the dumbest possible parser that you can get your job done with. It's a single file of C, and a single header file.

110 questions
2
votes
0 answers

CJSON length of parsed JSON

I tried out cJSON and discovered that even if I give an correct JSON followed by an incorrect JSON, it takes the entire content into its parse_buffer struct (in cJSON.c) and parses only the correct JSON. I can easily get the length of the total…
hw-135
  • 162
  • 1
  • 15
2
votes
1 answer

cJSON Key-Value Parsing

I am using cJSON to parse a JSON stored in testdata.json file which looks like this: { "text": "HelloWorld!!", "parameters": [{ "length": 10 }, { "width": 16 }, { "height":…
hw-135
  • 162
  • 1
  • 15
2
votes
1 answer

Memory Leak : Possible memory while scan through valgrind

I saw some random behavior while scanning my code through Valgrind. i have freed all possible memory blocks still I seeing Valgrind say 1 block is not properly freed. Objective: Creating the 3 level json by using cJSON.c then in the second block…
dragon
  • 132
  • 6
2
votes
1 answer

Get json value in lua using cjson

I have a json string encoded using json in lua for nginx. I have used cjson for encoding I need to get value of a json key. { "key1": "value1", "key2": value2, "content": { "key4": "value4" } } } How to get the value of key4 in…
Arpan Solanki
  • 817
  • 1
  • 17
  • 28
2
votes
1 answer

Redis cjson: Is there a way to manipulate JSON without decoding it completely?

Given the below example, is there a way to change the value from "bar" to "blah" without decoding them? redis 127.0.0.1:6379> eval 'return cjson.encode({["foo"]= "bar"})' 0 "{\"foo\":\"bar\"}" redis 127.0.0.1:6379> eval 'return…
rohitmohta
  • 1,001
  • 13
  • 22
2
votes
1 answer

lua cjson encode nil field

I have a lua table such as: local _table = {} _table["name"] = "some user name" _table["phone"] = nil ngx.say(cjson.encode(_table)) The ngx.say output as below: {"name":"some user name"} As you can see the phone field in _table has been…
Chunhui Zhang
  • 133
  • 2
  • 7
2
votes
1 answer

cjson - symbol(s) not found for architecture x86_64

I'm testing the library libcbor-0.5.0 for parsing and generating CBOR, https://libcbor.readthedocs.io/en/v0.5.0/index.html. All the examples run correctly, except cjson2cbor.c. It requires cJSON.h, so I added https://github.com/DaveGamble/cJSON to…
2
votes
1 answer

Make a makefile for cjson code with -lcjson for json parser in c

I'm very new to the makefiles. I'm compiling the c code file which contains cJson library from terminal using command gcc -test1.c -o test -lcjson with -lcjson at last and its running perfectly. But how to compile the same code using makefile as I…
Aditya
  • 23
  • 4
2
votes
1 answer

How cJSON parse the json array?

I have a question about the C parse the json array, I know how cJSON parse the json use C, but I can't find any result in Google about how to parse the json array, I have watched the Using cJSON to read in a JSON array, but it doesn't suit me. I…
Riko
  • 256
  • 1
  • 5
  • 15
2
votes
1 answer

modify json file using cJSON library

what i want to do is reading a json format file and modify it then writing the modified content to file. 55 cJSON *root,*basicpara; 56 char *out; 57 58 root = dofile("basicparameter.cfg"); 59 out = cJSON_Print(root); 60 …
sagarfan
  • 21
  • 4
2
votes
2 answers

cjson.decode() of a multi layer JSON

I want to decode a multi layered json object into a table and print the value of "temp". p=666 d=23.42 payload='{"d": {"pres":'..(p)..',"temp":'..(d)..'} }' t = cjson.decode(payload) My first idea was something like this:…
trahloff
  • 607
  • 1
  • 9
  • 17
2
votes
1 answer

How to parse JSON response in C Linux?

I have used many tools such as cJSON, nxjson and jsmn parsers to parse the JSON response but none of the tools which i had used is giving the output in some structure format. Below is my JSON response in…
2
votes
3 answers

cJSON: can't understand something of it's source code

When I read the code of cJSON, and have problem understanding the code: static void *(*cJSON_malloc)(size_t sz) = malloc; static void (*cJSON_free)(void *ptr) = free;
colin
  • 41
  • 6
2
votes
4 answers

Using malloc with a structure and strcpy

I'm attempting to make an array of the structure I made called StatusItem, which looks like this: typedef struct { char* name; char* index; int optional; } StatusItem; Also, as I want this array to be of any size, I am using malloc. …
Nealon
  • 2,213
  • 6
  • 26
  • 40
1
vote
1 answer

C HTTP post request getting a second response (400 Bad Request) after first 200 OK

I've been struggling with this issue for a while so it's time to ask for help. System: nRF9160 microcontroller running Zephyr RTOS using cellular modem to post to endpoints running on GCP Problem: I am using Zephyr's socket functions (which are…