- This topic has 3 replies, 2 voices, and was last updated 4 years, 11 months ago by .
Viewing 3 reply threads
Viewing 3 reply threads
- You must be logged in to reply to this topic.
Tagged: Delphi kbmMW JSON
Hi Kim!
In trying to parse the JSON packet that comes back from this test URL:
014032%3D%7D013032%26%2C1000000000000XYZ12″>https://accessgudid.nlm.nih.gov/api/v2/devices/lookup.json?udi=%3D%2F08717648200274%3D%2C000025%3DA99971312345600%3D>014032%3D%7D013032%26%2C1000000000000XYZ123
…and using this source code to parse it:
procedure TForm1.Button1Click(Sender: TObject);
var
json: TkbmMWJSONObject;
stream: TkbmMWJSONStreamer;
s: String;
bytes: TkbmMWBytes;
begin
stream := TkbmMWJSONStreamer.Create;
try
s := http.Get(KURLNLMAccessGUDID + KUDISample);
memo1.Text := s;
SetLength(bytes,Length(AnsiString(s)));
Move(s[1],bytes[0],Length(AnsiString(s)));
json := TkbmMWJSONObject(stream.LoadFromUTF8String(bytes));
finally
stream.Free;
end;
end;
…I get the following error:
Syntax error. Expected identifier. : Pos 2 :
If I use the Delphi 10.3 Enterprise REST Debugger tool, the JSON packet is properly parsed, is reported as properly formed JSON, and is displayed as a pretty formatted JSON tree.
Also, if I try to pass a UnicodeString to the stream.LoadFromUTF16String(s), I get an access violation in the call to kbmMWJSON.TkbmMWJSONStreamer.ExpectNumber, line# 720.
kbmMW 5.06.20
Delphi 10.3 Enterprise
Works fine in my tests. Something else must be happening.
Try to open the ObjectNotation demo, and paste the JSON you have received in a browser, directly into the JSON parsing part, and let it parse. Here it works fine (using 5.09)
best regards
Kim/C4D
I tried this with the objectNotation demo. I pasted in the JSON packet. I hit the ‘Parse’ button. I get an access violation.
Delphi 10.3 Enterprise
kbmMW 5.06.20
I suggest you to update to a later kbmMW version since it works fine in 5.09.
best regards
Kim/C4D