During the development of DBXJSON in DelphiXE, I ran into a couple of problems
An example of a JSON response that we will parse:
{"num1":631, "num2":31, "num3":64, "data":"{ \"dat1\":[0,1,2,3,4], \"dat2\":null, \"dat3\":true, \"dat4\":[1,1,1,1,1], \"dat5\":{ \"dat4str1\":11, \"dat4str2\":0, \"dat4str3\":0, \"dat4str4\":2 }, \"sdata\":{ \"sdata1\":12, \"sdata2\":48, \"sdata3\":395, }, \"dat5\":[[0,1,1],[0,1,1],[0,1,1]] }" } 1 . If the answer is in JSONText, then we get the whole object:
JSONObj:=TJSONObject.ParseJSONValue(JSONText) As TJSONObject; Then select the data in a separate:
JSONData:=TJSONObject.ParseJSONValue(JSONObj.Get('data').JsonValue.Value) As TJSONObject; And then you also need to select dat5, but the line:
JSONData4:=TJSONObject.ParseJSONValue(JSONData.Get('dat5').JsonValue.Value) As TJSONObject; will not work, because of the slash in the name \ "dat5 \"
How to be? From php kstati everything parsitsya with a bang.
2 How to read null and true values?