Page 1 of 1

Remove double quotes before saving SetJSONString() ?

Posted: Mon Oct 07, 2024 12:32 pm
by hdt888
I need to save a json file, in the form:

Code: Select all

{
ok:true
}

or 
{
ok:false
}
But when use SetJSONString(), result as:

Code: Select all

{
ok:"true"
}

or 
{
ok:"false"
}
How to remove double quotes before/after saving SetJSONString() ?

Thank you for help.

Re: Remove double quotes before saving SetJSONString() ?

Posted: Mon Oct 07, 2024 12:45 pm
by Fred

Re: Remove double quotes before saving SetJSONString() ?

Posted: Mon Oct 07, 2024 12:49 pm
by Kiffi
It is logical that if you use SetJSONString(), you also set a string with quotes.

BTW: Your json is not valid anyway:
{
ok:true
}

Code: Select all

If CreateJSON(0)
  ObjectValue = SetJSONObject(JSONValue(0))
  SetJSONBoolean(AddJSONMember(ObjectValue, "ok"), #True)
  Debug ComposeJSON(0, #PB_JSON_PrettyPrint)
EndIf
creates:
{
"ok": true
}