3

I need to parse JSON Boolean value in Inno Setup. I've tried to modify the code from How to parse a JSON string in Inno Setup? to parse Booleans like this:

function FindJsonBoolean(
  Output: TJsonParserOutput; Parent: TJsonObject; Key: TJsonString;
  var Bool: TJsonBool): Boolean;
var
  JsonValue: TJsonValue;
begin
  Result :=
    FindJsonValue(Output, Parent, Key, JsonValue) and
    (JsonValue.Kind = JVKBoolean);
  if Result then
    begin    
      Bool := Output.Boolean[JsonValue.Index]; 
    end;
end;

But it fails to compile with:

Unknown type 'TJsonBool'

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Crtac
  • 61
  • 9

1 Answers1

2

There's no TJsonBool in the JsonParser library. There's:

TJsonWord = (JWUnknown, JWTrue, JWFalse, JWNull);

Use something like this and compare TheWord with JWTrue/JWFalse.

function FindJsonWord(
  Output: TJsonParserOutput; Parent: TJsonObject; Key: TJsonString;
  var TheWord: TJsonWord): Boolean;
var
  JsonValue: TJsonValue;
begin
  Result :=
    FindJsonValue(Output, Parent, Key, JsonValue) and
    (JsonValue.Kind = JVKWord);

  if Result then
  begin    
    TheWord := Output.Words[JsonValue.Index]; 
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992