json upload code

 Hi,

I have a question, i'm at this moment made a emoncms environment by myself (At least it is part of an existing environment).

The part of the API key is working only i have a little problem with the json string, the nanode skech is sending the next string: /api.php?apikey=91f9536a7fbcf77c9f824eb4edc7d780&json={temp1:20.1,temp2:31.2}

and it must be :

/api.php?apikey=91f9536a7fbcf77c9f824eb4edc7d780&json={"temp1":"20.1","temp2":"31.2"}

with the quots, now i have try to insert it manual like this:
{"temp1":"%d",""temp2':"%d"}

but this give me a error, is there something more a can try?

I like to hear it.
Regards,
DJ
 

 

 

 

reubenb87's picture

Re: json upload code

To add quotes (") to sprintf you need to put escape character /

sprintf(str,"{\"temp1\":\"%d\",\"temp2\":\"%d\"}", var1,var2);

Look at this page for more characters you need to do this with: http://www-teaching.physics.ox.ac.uk/computing/handbook_c/node32.html

 

Regards,

Reuben

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.