CreateJsonNull ( )
Parameters
| None. |
Description
|
Creates an owned JSON null value. JSON null is a real value with a real positive handle - it is never the 0 that signals a failed parse or lookup. That distinction lets a save file say "this slot is deliberately empty" (an unclaimed equipment slot, no guild joined yet) and lets your code tell that apart from "this field does not exist at all". Test for it with JsonIsNull, or check that JsonKind returns JSON_NULL. The returned handle is owned by you: release it with FreeJson. When you store a null into a container, the setter copies it, so free your temporary handle straight afterwards. For the full rules, see the Application Data language reference. Requires Extended mode. See also: JsonIsNull, JsonKind, CreateJsonObject, JsonObjectSet, FreeJson. |
Example
; CreateJsonNull Example ; ---------------------- ; Requires Extended mode. ; JSON null is a real value with a real (positive) handle - ; not the zero that signals a failed parse or lookup. empty_slot=CreateJsonNull() Print "Handle for JSON null: "+empty_slot+" (positive, not zero)" Print "JsonIsNull says: "+JsonIsNull(empty_slot) Print "Kind is JSON_NULL: "+(JsonKind(empty_slot)=JSON_NULL) Print "" ; A save-game can use null for an unclaimed equipment slot save=CreateJsonObject() JsonObjectSet save,"ring_slot",empty_slot Print "In a save file: "+JsonStringify(save,0) FreeJson save FreeJson empty_slot Print "" Print "Press any key to close the example" WaitKey End
Index