; JsonObjectSet Example
; ---------------------

q$=Chr(34)  ; Double-quote character, for building JSON text

; A save-game record in progress
save=ParseJson("{"+q+"player"+q+":"+q+"Aria"+q+","+q+"level"+q+":7}")
Print "Start:        "+JsonStringify(save,0)

; JsonObjectSet copies the value into the object under a key -
; a brand-new key is added at the end
v=CreateJsonInteger(1250L)
JsonObjectSet save,"gold",v
FreeJson v
Print "Added gold:   "+JsonStringify(save,0)

; Replacing an existing key keeps its original position -
; 'level' stays second, it does not jump to the end
v=CreateJsonInteger(8L)
JsonObjectSet save,"level",v
FreeJson v
Print "Level up!     "+JsonStringify(save,0)
Print ""
Print "Note 'level' kept its place when replaced."

FreeJson save

Print ""
Print "Press any key to close the example"
WaitKey

End
