#include "json_h.fos"
JSON@ poems = JSONLoad("poems.json");
JSON@ poemYear = poems[0]["year"];
if (poemYear.isUndefined())
{
Log("No year? Oh noes."); return;
}
int year = 0;
poemYear >> year;
JSON Value type | Compatible data types |
Undefined | - |
Null | - |
Boolean | bool |
Number | int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float, double |
String | string, string@ |
Object | - |
Array | array<bool>, array<string>, array<string@>, array<int>, array<int8>, array<int16>, array<int32>, array<int64>, array<uint>, array<uint8>, array<uint16>, array<uint32>, array<uint64>, array<float>, array<double> |
poems[2]["title"] << "The title of the third poem got hacked!";
_JSON_ForEach(poems, @LogPoemTitle);
void LogPoemTitle(JSON@ poem, uint index)
{
string title = "No title";
poem["title"] >> title;
Log("Poem " + index + ": \"" + title + "\"");
}
poems.forEach(@LogPoemTitle);
poems[2].save("hacked_poem.json");
{
"title": "The title of the third poem got hacked!",
"year": 1784,
"song": false,
"text": [
"Roses are red,",
"Violets are blue,",
"Sugar is sweet,",
"And so are you."
]
}
Great stuff, thank you for creating this!
What can I say, not maintained code :)
(...)
Anyone have an idea how to get it to work?