mg_http_reply() with JSON problem #3317
Replies: 1 comment
-
| Please see our documentation, and follow the guidelines in our tutorials. There are lots of examples on how to use those functions | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. Having troubles with code like this:
#define MY_ID 0x600D1DE4 //number
#define FW_VERSION_STRING "0.0.48" //I expect string here, but mongoose making some sort of number of it (causing parser error)
#define HW_VERSION_STRING "2.0" //number here as well instead of string produced by mongoose
Code like this crashes the app:
mg_http_reply(c, 200, s_json_header, "{%m:%m,%m:%d,%m:%s,%m:%s}\n",
MG_ESC("NAME"), MG_ESC("MG"),MG_ESC("ID"),MY_ID,
MG_ESC("FW"), MG_ESC(FW_VERSION_STRING),
MG_ESC("HW"), MG_ESC(HW_VERSION_STRING)); //->smells like something not being catched by mongoose eventhough user applied wrong inputs
Code like this does not produce string fields in JSON, but making numbers instead:
mg_http_reply(c, 200, s_json_header, "{%m:%m,%m:%d,%m:%s,%m:%s}\n",
MG_ESC("NAME"), MG_ESC("MG"),MG_ESC("ID"),MY_ID,
MG_ESC("FW"), FW_VERSION_STRING,
MG_ESC("HW"), HW_VERSION_STRING); //devTools->{"NAME":"MG","ID":1611472356,"FW":0.0.48,"HW":2.0}
Any ideas about fixing it, please?
Beta Was this translation helpful? Give feedback.
All reactions