How to parse json?

my original json string is getting from get request is

{"hour":"[10,14,18]","level":"[25,50,80]","maxdist":110}

for this i get error while compiling as " expected ',' or ';' before 'hour' "

but when i add slash to it like this

"{"hour":[10,14,18],"level":[25,50,80],"maxdist":110}";

all values i can get perfectly....

so how to add those slashes

i gone through this link but didn't get

Your nested double quotes need to be escaped as "this is \"someQuotedText\" inside a string"

And these “slashes” are actually “back-slashes” and you should find a key on your keyboard to enter them in your code :wink:

These backslashes never really end up as part of the string but they are only a convention how to code quoted sub-strings inside a string.
This is something inherently C/C++ related and is nothing Particle specific, hence getting the C/C++ basics straight might be a basic step in order to successfully write C/C++ code :sunglasses:

1 Like

here i changed my response

“{‘hour’:[10,14,18],‘level’:[25,50,80],‘maxdist’:110}”;

it working ok

Hi viraj,

Please help me to solve the JSON parsing for 3 values from server side.
I dont know how to send the JSON string from ubuntu CLI please help me if you know

use the arduino json libarary for parsing values
and also sample examples are there

1 Like

Try pasting your json in this validator for valid json - it is a lot easier than trial and error!

https://jsonformatter.curiousconcept.com/