crow icon indicating copy to clipboard operation
crow copied to clipboard

JSON parser response

Open Shriyanshmit opened this issue 5 years ago • 1 comments

I want inner JSON object please let me know how I can create the same as mentioned below. I tried with below code. Please help this code is throwing error.

// simple json response CROW_ROUTE(app, "/json") ([]{ crow::json::wvalue x; x["Status"] = true; x["ErrorMessage"] = "No Error";

	crow::json::wvalue y;  
	y["IsValidUser"] = true;
	y["Prop2"] = "No Error";	    

	x["ResponseData"] = y;

	
		return x;		
});	

I want the same response as mentioned below.

{"ResponseData":{ "IsValidUser":true,"Prop2":"No Error"},"Status":true,"ErrorMessage":"No Error"}

Shriyanshmit avatar Mar 18 '20 08:03 Shriyanshmit

I use jsoncons, it's way simpler than crow::json, although you do need to set_header("Content-Type", "application/json") and dump the json string into the response body.

The-EDev avatar Oct 03 '20 08:10 The-EDev