Skip to main content

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


Methods

isNull

json:isNull(jsonString: string): bool

Parameters:

ParameterTypeDefaultDescription
jsonStringstring-

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:

ParameterTypeDefaultDescription
jsonStringstring-

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:

ParameterTypeDefaultDescription
arrayarray-

Returns a json string with the contents of the specified table.

Example

print(json.serialize({
Name = "Cool Sword",
Damage = 10,
}))