DecodeFromString
Load JSON code from string variable.
Call:
int ires = ts_json(int iJSONObjectDescr, "DecodeFromString", string sJSON);
Here:
iJSONObjectDescr - descriptor of the JSON type object into which the code should be loaded,
sJSON is a string variable that contains JSON text.
Returns 0 on successful upload.
Example.
Load JSON code from string.
int iJSONConfig; // object descriptor ts_json
object("create", "ts_json", iJSONConfig); // create object in memory
string sJSON = "{ \"My class in JSON code\":{\
\"StringVariable\":\"my string\",\
\"DoubleVariable\" : 1.23\
}}";
int ires = ts_json(iJSONConfig, "DecodeFromString", sJSON);
if (ires != 0)
{
cout << "JSON Decode from URL error";
}
else
{
cout << "File JSON decoded successfully\n";
}
object("delete", iJSONConfig); // delete object