json
json is a module which allows for scripts to interface with JSON data representation by converting it to a table and vice versa.
Summary
Methods
isNull:boolnull:string:voidparse:Tableserialize:string
Methods
isNull
json:isNull(jsonString: string): bool
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
jsonString | string | - |
Returns true if the value specified is a null read from a json string
Example
print(json.isNull("{}"))
null:string
json:null:string()
Returns a special value which is a representation of a null in a json
Example
print(json.null())
parse
json:parse(jsonString: string): Table
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
jsonString | string | - |
Returns a table with the contents of the specified JSON string
Example
Http:Get("https://api.polytoria.com/v1/asset/owner?userID=1&assetID=234", function (data, error, errmsg)
if error then
print("Something went wrong!")
return
end
print(json.parse(data)["Success"])
end)
serialize
json:serialize(array: array): string
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
array | array | - |
Returns a json string with the contents of the specified table.
Example
print(json.serialize({
Name = "Cool Sword",
Damage = 10,
}))