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'
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With