Error parsing JSON data packet

Home Forums kbmMW Error parsing JSON data packet

Viewing 3 reply threads
  • Author
    Posts
    • #53991
      David Keith
      Participant

      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

    • #53992
      kimbomadsen
      Keymaster

      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

    • #53993
      David Keith
      Participant

      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

    • #53996
      kimbomadsen
      Keymaster

      I suggest you to update to a later kbmMW version since it works fine in 5.09.

      best regards

      Kim/C4D

Viewing 3 reply threads
  • You must be logged in to reply to this topic.