; CopyJson Example
; ----------------

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

; The current save-game
save=ParseJson("{"+q+"player"+q+":"+q+"Aria"+q+","+q+"gold"+q+":1250}")

; CopyJson makes a fully independent deep copy - a backup slot
backup=CopyJson(save)

; Spend some gold in the live save only
v=CreateJsonInteger(200L)
JsonObjectSet save,"gold",v
FreeJson v

Print "Live save:   "+JsonStringify(save,0)
Print "Backup copy: "+JsonStringify(backup,0)
Print ""
Print "The backup kept gold=1250 - the copy shares nothing with the original."

; Both handles are owned and must be freed separately
FreeJson backup
FreeJson save

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

End
