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
0
votes
0 answers

CJson - Insert missing quotes around strings

I have a text file of format given below (this is just sample file, but actually file is big one with key, values). Some of the values for the key will have format in file (look for value of Port key in below file). This is input file for me. I am…
0
votes
1 answer

How to parse the following object in cJSON in generic way

As i am new to the cJOSN parser, someone please help to parse the following json in a generic way. Here name and Strength is fixed. So if i choose person1, have to get person1's name and strength key values.(Number of persons may increase or…
0
votes
1 answer

How to find a name in a name/value pair using cJSON

cJSON provides a function CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) I created a test function #include "cJSON.h" const char *jsonstring = "{\"b\": {\"b1\":\"2b\"}}"; void…
KeithSmith
  • 774
  • 2
  • 8
  • 26
0
votes
0 answers

lua - check if userdata is nil

I trying to use lua cjson to parse to following json : { "data" : null, "message" : "Your session has expired. Please login again.", "code" : "390112", "success" : false } it's parsed to the following map…
Eyal leshem
  • 995
  • 2
  • 10
  • 21
0
votes
0 answers

Installing CJSON in lua with make and luarocks fails

my aim is to install cjson with luarocks on Windows 10 (64 Bit), what i've done so far: Try the installation via make: put this luajit installation on the path "C:\torch" and set all the following path variables manually (see issues) Path =…
Joey
  • 1
  • 1
0
votes
2 answers

read keys using cJSON

I am using cJSON to parse a string containing key-values. I want to generate my structure dynamically and for that I need to read all the keys from this string. e.g. I have a json like below and I want to read all the keys at run-time. I don't know…
Shaila
  • 51
  • 7
0
votes
1 answer

C - How to convert wide char Japanese characters to UTF-8?

Trying to convert Japanese characters stored in wide char to UTF-8, in order to store the value in a json file using cJSON library. First tried using wcstombs_s but apparently this does not support Japanese characters: size_t len =…
evilmandarine
  • 4,241
  • 4
  • 17
  • 40
0
votes
1 answer

Using cJSON issue in reading JSON array elements

I am writing a small piece of c code to parse json array elements using cJSON library in gcc. The parsing is successful but printing of array elements turn up as null. Not sure what is the issue. Need to pass json array input of src, dst and list of…
UserM
  • 190
  • 2
  • 19
0
votes
0 answers

How to fix 'Error: Build error: Failed installing cjson.dll'

I want to install lua-cjson, and I get this error when running luarocks install lua-cjson Error: Build error: Failed installing cjson.dll My version of cl is https://i.stack.imgur.com/djC5S.jpg My luarocks version is: luarocks 2.0.2 LuaRocks main…
OverHash
  • 3
  • 1
  • 4
0
votes
1 answer

How to translate between cJSON and protobuf bytes variable

I'm using protobuf-c library and a cJSON and I have protobuf message with field bytes args = 1; // Command-specific payload I'm parsing cJSON to protobuf like this: args = cJSON_GetObjectItemCaseSensitive(command, "args"); if (args) { …
0
votes
3 answers

How to use GTK and libcurl at the same time in C?

I'm trying to develop an application in C with GTK for the GUI, libcurl to get data by a web API and cJSON to parse JSON. My problem is that when I do my request with libcurl after gtk_init, the data that I get can not be parsing in JSON. Otherwise,…
0
votes
2 answers

How to return cJSON fragments by process parent using POSIX?

tl;dr: How I can I configure cJSON to allocate memory in child processes, so that the parent can see the resulting structs? I have a request that comes in that lists multiple products for which summaries are to be generated and returned as JSON.…
Sled
  • 18,541
  • 27
  • 119
  • 168
0
votes
2 answers

How to convert uint8_t from uart_read_bytes to a char or something that can be added to cJSON object?

Here I am reading from a UART that is communicating with another device that is sending it bytes. If I am getting an integer value in 3 bytes, how best to convert it to something I can send using cJSON. I can get the value and iterate over it, but…
wegunterjr
  • 141
  • 2
  • 9
0
votes
0 answers

I am not able to parse huge json file by using cjson in effective way but the cjson library is good to implement

I want to parse a huge json with more accuracy and less code implementation. Is there any possibility to implement.i am able to parse a huge file into the buffer but when I try to access values of json I need to do individually for all the keys and…
0
votes
1 answer

How to test for a Boolean being TRUE/FALSE in cJSON

I'm parsing a json file with cJSON. Everything is going well. But one of the data elements is a Boolean, and the problem is I don't understand how to use cJSON's functions for reading Boolean types. The data file contains lines like: "isDaytime":…
Terry Wendt
  • 28
  • 1
  • 7