JSON: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 2: Line 2:
Load a [[wp:JSON|JSON]] string into a data structure. Also create a new data structure and serialize it into JSON.
Load a [[wp:JSON|JSON]] string into a data structure. Also create a new data structure and serialize it into JSON.
Use objects and arrays (as appropriate for your language) and make sure your JSON is valid (http://www.jsonlint.com/).
Use objects and arrays (as appropriate for your language) and make sure your JSON is valid (http://www.jsonlint.com/).

=={{header|C++}}==
<lang cpp>#include "Core/Core.h"

using namespace Upp;

CONSOLE_APP_MAIN
{
JsonArray a;
a << Json("name", "John")("phone", "1234567") << Json("name", "Susan")("phone", "654321");
String txt = ~a;
Cout() << txt << '\n';
Value v = ParseJSON(txt);
for(int i = 0; i < v.GetCount(); i++)
Cout() << v[i]["name"] << ' ' << v[i]["phone"] << '\n';
}
</lang>


=={{header|C sharp}}==
=={{header|C sharp}}==