InsertJsonList change structure order... NO Bug

Just starting out? Need help? Post your questions and find answers here.
drgolf
Enthusiast
Enthusiast
Posts: 117
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

InsertJsonList change structure order... NO Bug

Post by drgolf »

Hello,

This code give strange result :

Code: Select all

Structure mystruct 
  tz.s
  pz.s
  uz.s
EndStructure

NewList mylist.mystruct()

*e.mystruct

*e=AddElement(mylist())
*e\tz="aaa"
*e\pz="bbb"
*e\uz="ccc"
;
*e=AddElement(mylist())
*e\tz="ddd"
*e\pz="eee"
*e\uz="fff"

If CreateJSON(0); , #PB_JSON_NoCase)
  InsertJSONList(JSONValue(0),mylist())
  Debug ComposeJSON(0,#PB_JSON_PrettyPrint)
  
EndIf

I want this result :

Code: Select all

[
  {   
    "tz": "aaa",
    "pz": "bbb",
    "uz": "ccc"
  },
  {    
    "tz": "ddd",
    "pz": "eee",
    "uz": "fff"
  }
]

Is this possible ? A bug ? Missing something ?

Any help appreciated...
Last edited by drgolf on Mon May 19, 2025 5:32 pm, edited 1 time in total.
User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: InsertJsonList change structure order... Bug ???

Post by Kiffi »

No bug.
Little John wrote:A JSON object by definition is an unordered collection of name/value pairs
See: viewtopic.php?t=69100
Hygge
drgolf
Enthusiast
Enthusiast
Posts: 117
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Re: InsertJsonList change structure order... Bug ???

Post by drgolf »

Thanks Kiffi.

I use Jsave module and all works great.

No bug.
Post Reply