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
1
vote
1 answer

How to handle POST request with JSON payload on ESP32 server?

I am trying to receive json data from http server on ESP32, but I get core panic every time I try to access data inside my json. POST request is done using simple html form:
vict
  • 158
  • 1
  • 11
1
vote
0 answers

cJSON parsing without knowing the name of the keys or the datatype of the values

I am writing a program which needs to parse a json I don't know the exact format. The important data can be stored in multiple possible keys. For simplicity's sake let's say the names of the keys can be either "A" or "B". I don't know which it will…
notAuser
  • 31
  • 3
1
vote
2 answers

how to add lua-cjson to my nginx lua container?

I am using this docker-compose to create a Lua supported Nginx: version: '3.9' services: nginx: container_name: local_nginx image: fabiocicerchia/nginx-lua environment: - REDIS_SERVER=172.26.0.1 ports: - 8089:80 …
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
1
vote
1 answer

Parse JSON with missing fields using cjson Lua module in Openresty

I am trying to parse a json payload sent via a POST request to a NGINX/Openresty location. To do so, I combined Openresty's content_by_lua_block with its cjson module like this: # other locations above location /test { …
albert
  • 8,027
  • 10
  • 48
  • 84
1
vote
1 answer

Calculate the byte size of a cJSON object

Right now I'm struggling with calculating the size of a cJSON object. So far, I have done this: cJSON *payload = cJSON_CreateObject(); ... size_t size_payload = sizeof(payload); Obviously I initialize the payload object and I print into the…
Carlos
  • 11
  • 2
1
vote
1 answer

How to add an open source library to CLion in a Mac?

I want to use (cJSON) library in my c++ code. How do I download and add this library to my CLion project in order to import it into my code like this #include This is my cMakeLists.txt cmake_minimum_required(VERSION…
Command
  • 515
  • 2
  • 6
  • 19
1
vote
0 answers

undefined symbol: lua_rotate

I had done below steps, downloaded lua-cjson-2.1.0.7 from this repo, Not really know what went wrong. can anybody know whats going on and how to resolve this? make install mkdir -p /usr/local/lib/lua/5.1 rm -f /usr/local/lib/lua/5.1/cjson.so cp…
Satscreate
  • 495
  • 12
  • 38
1
vote
1 answer

How to check if a cJSON pointer was initialized/set earlier?

I have a struct with cJSON pointers as in: struct { cJSON *myJSON1; cJSON *myJSON2; ... } myStruct; Somewhere in my code I create cJSON items as in myStruct.myJSON1 = cJSON_CreateObject() At the end of the code, I want to…
asinix
  • 966
  • 1
  • 9
  • 22
1
vote
3 answers

Using cJSON in windows

I want to use cJSON library on windows with clion. I have copied cJSON.h and cJSON.c to my project directory. I have included cJSON.h with this command: #include "cJSON.h" When I try to compile my project, I get these…
1
vote
1 answer

Why my program crashes after second usage of a string in different functions?

When I run my program , it calls a function that have a "char *msgtype" and this function work probably but when another function use a different "char *msgtype" in it when program reach the line that contain it , program crashes(and even when the…
Ali Hatami
  • 144
  • 10
1
vote
0 answers

Converting cjson json to string

I am using cjson library to create json and send it to server. I am using following code char *string = cJSON_Print(json); For which I get following output { "type1": "car", "type2": "bus", } But the server expects it in string format like…
prattom
  • 1,625
  • 11
  • 42
  • 67
1
vote
0 answers

parsing json using cjson

I want to parse the json {"endtime":"", "status":"on"} and the timestamp contains something like 3/27/2019 7:40:47 AM. my code is given below: cJSON * root = cJSON_Parse(buffer); cJSON * name = cJSON_GetObjectItem(root,…
Nazna AA
  • 11
  • 3
1
vote
1 answer

How to check for nil/null in Redis' Lua cjson?

I have a lua script with code block as below: local call_data = cjson.decode(ARGV[1]) local other_data = cjson.decode(ARGV[2]) local data = {} local next = next local populate_data = function(source) if next(source) == nil…
Jaswinder
  • 1,455
  • 14
  • 27
1
vote
1 answer

cjson decode in Lua returns array of empty arrays redis-cli

I've got a large JSON array of objects stored in redis as an encoded string. local string_foo = redis.call("get",…
phillercode
  • 339
  • 1
  • 14
1
vote
2 answers

cJSON field does not exist

I have a JSON array as follows. I am using cJSON to parse it. However, I want to check if a field exists in my array. I have tried to use cJSON_GetObjectItem and cJSON_IsNull and compare its return value to NULL to determine if a field does not…
skmiley1
  • 249
  • 2
  • 11