Remove double quotes before saving SetJSONString() ?

Just starting out? Need help? Post your questions and find answers here.
hdt888
User
User
Posts: 57
Joined: Sun Jul 07, 2024 8:42 am

Remove double quotes before saving SetJSONString() ?

Post 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.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Remove double quotes before saving SetJSONString() ?

Post by Fred »

User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Remove double quotes before saving SetJSONString() ?

Post 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
}
Hygge
Post Reply