Can Chilkat validate json?

17 views Asked by At

Making first steps with the Chilkat library, specifically the json part.

Using the excellent examples and documentation it's simple enough to build a working demo.

However I can't figure out how to evaluate the structure of the JSON. I know that Chilkat specifically will not ever throw exceptions. But when do I know if the JSON parses at all ?

Specifically the following returns "succes" as long as the file exists.

procedure TForm1.btnLoadJsonClick(Sender: TObject);
var
    json: HCkJsonObject;
    success: Boolean;
begin
    json := CkJsonObject_Create();

    try
    success := CkJsonObject_LoadFile(json,'ChilkatDelphi32.dll');
    if (success <> True) then
      begin
        mmo1.Lines.Add(CkJsonObject__lastErrorText(json));
        Exit;
      end;
    finally
    
       CkJsonObject_Dispose(json);
    end;
end;

I do get an error if I use the structure and the key is not found, so Chilkat error handling works. But that won't tell if the json structure is invalid, instead any invalid data is handled transparently.

Anyway Chilkat can parse the JSON for validity ?

0

There are 0 answers