JSON: Difference between revisions

377 bytes added ,  12 years ago
no edit summary
No edit summary
No edit summary
Line 2:
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/).
 
=={{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}}==
Anonymous user