Json
Functions
Section titled “Functions”The empty Json
object returned can be filled with data and read by the functions and procedures prefixed with json_add_
and json_read_
Return Type: Json
Signatures:
json create_json()
public static Json SplashKit.CreateJson();public Json();
def create_json():
function CreateJson(): Json
Usage: {</>}
string json_string
must be valid JSON. The Json
object returned can be filled with data and read by the functions and procedures prefixed with json_add_
and json_read_
Parameters:
Name | Type | Description |
---|---|---|
json_string | String | The JSON formatted String to be converted to a Json object. |
Return Type: Json
Signatures:
json create_json(string json_string)
public static Json SplashKit.CreateJson(string jsonString);public Json(string jsonString);
def create_json_from_string(json_string):
function CreateJson(jsonString: String): Json
Releases all of the Json
objects which have been loaded.
Signatures:
void free_all_json()
public static void Json.FreeAll();public static void SplashKit.FreeAllJson();
def free_all_json():
procedure FreeAllJson()
Usage: {</>}
Frees the SplashKit resources associated with the Json
object.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object whose resources should be released. |
Signatures:
void free_json(json j)
public static void SplashKit.FreeJson(Json j);
def free_json(j):
procedure FreeJson(j: Json)
Usage: {</>}
Returns the count of keys in the top-level Json
object.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object to count keys. |
Return Type: Integer
Signatures:
int json_count_keys(json j)
public int Json.CountKeys();public static int SplashKit.JsonCountKeys(Json j);
def json_count_keys(j):
function JsonCountKeys(j: Json): Integer
Converts a Color
to a Json
object.
Parameters:
Name | Type | Description |
---|---|---|
clr | Color | The Color to convert to Json . |
Return Type: Json
Signatures:
json json_from_color(color clr)
public static Json SplashKit.JsonFromColor(Color clr);
def json_from_color(clr):
function JsonFromColor(clr: Color): Json
Reads a Json
object from a JSON string stored in Resources/json/filename
and loads the data into the returned Json
object.
Parameters:
Name | Type | Description |
---|---|---|
filename | String | The filename of the file to be written to Resources/json/ . |
Return Type: Json
Signatures:
json json_from_file(const string &filename)
public static Json Json.FromFile(string filename);public static Json SplashKit.JsonFromFile(string filename);
def json_from_file(filename):
function JsonFromFile(const filename: String): Json
Usage: {</>}
Reads a Json
object from a String
in the JSON format.
Parameters:
Name | Type | Description |
---|---|---|
j_string | String | A String in the JSON format. |
Return Type: Json
Signatures:
json json_from_string(const string &j_string)
public static Json Json.FromJsonString(string jString);public static Json SplashKit.JsonFromString(string jString);
def json_from_string(j_string):
function JsonFromString(const jString: String): Json
Usage: {</>}
Checks if the Json
object contains the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object to check for the given key. |
key | String | The String key to be checked. |
Return Type: Boolean
Signatures:
bool json_has_key(json j, string key)
public bool Json.HasKey(string key);public static bool SplashKit.JsonHasKey(Json j, string key);
def json_has_key(j, key):
function JsonHasKey(j: Json; key: String): Boolean
Usage: {</>}
Reads an array of Double
values from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
out_result | Vector | The array which will be filled with the data stored for String key. |
Signatures:
void json_read_array(json j, string key, vector<double> &out_result)
public void Json.ReadArray(string key, ref List<double> outResult);public static void SplashKit.JsonReadArray(Json j, string key, ref List<double> outResult);
def json_read_array_of_double(j, key, out_result):
procedure JsonReadArray(j: Json; key: String; var outResult: ArrayOfDouble)
Reads an array of Json
object values from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
out_result | Vector | The array which will be filled with the data stored for String key. |
Signatures:
void json_read_array(json j, string key, vector<json> &out_result)
public void Json.ReadArray(string key, ref List<Json> outResult);public static void SplashKit.JsonReadArray(Json j, string key, ref List<Json> outResult);
def json_read_array_of_json(j, key, out_result):
procedure JsonReadArray(j: Json; key: String; var outResult: ArrayOfJson)
Reads an array of String
values from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
out_result | Vector | The array which will be filled with the data stored for String key. |
Signatures:
void json_read_array(json j, string key, vector<string> &out_result)
public void Json.ReadArray(string key, ref List<string> outResult);public static void SplashKit.JsonReadArray(Json j, string key, ref List<string> outResult);
def json_read_array_of_string(j, key, out_result):
procedure JsonReadArray(j: Json; key: String; var outResult: ArrayOfString)
Usage: {</>}
Reads an array of Boolean
values from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
out_result | Vector | The array which will be filled with the data stored for String key. |
Signatures:
void json_read_array(json j, string key, vector<bool> &out_result)
public void Json.ReadArray(string key, ref List<bool> outResult);public static void SplashKit.JsonReadArray(Json j, string key, ref List<bool> outResult);
def json_read_array_of_bool(j, key, out_result):
procedure JsonReadArray(j: Json; key: String; var outResult: ArrayOfBoolean)
Reads a Boolean
value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: Boolean
Signatures:
bool json_read_bool(json j, string key)
public bool Json.ReadBool(string key);public static bool SplashKit.JsonReadBool(Json j, string key);
def json_read_bool(j, key):
function JsonReadBool(j: Json; key: String): Boolean
Reads a Float
value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: Float
Signatures:
float json_read_number(json j, string key)
public float Json.ReadNumber(string key);public static float SplashKit.JsonReadNumber(Json j, string key);
def json_read_number(j, key):
function JsonReadNumber(j: Json; key: String): Single
Reads a Double
value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: Double
Signatures:
double json_read_number_as_double(json j, string key)
public double Json.ReadDouble(string key);public static double SplashKit.JsonReadNumberAsDouble(Json j, string key);
def json_read_number_as_double(j, key):
function JsonReadNumberAsDouble(j: Json; key: String): Double
Reads a integer
value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: Integer
Signatures:
int json_read_number_as_int(json j, string key)
public int Json.ReadInteger(string key);public static int SplashKit.JsonReadNumberAsInt(Json j, string key);
def json_read_number_as_int(j, key):
function JsonReadNumberAsInt(j: Json; key: String): Integer
Usage: {</>}
Reads a Json
object value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: Json
Signatures:
json json_read_object(json j, string key)
public Json Json.ReadObject(string key);public static Json SplashKit.JsonReadObject(Json j, string key);
def json_read_object(j, key):
function JsonReadObject(j: Json; key: String): Json
Usage: {</>}
Reads a String
value from the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object from which data will be returned for the given key. |
key | String | The String key used to find data in the Json object. |
Return Type: String
Signatures:
string json_read_string(json j, string key)
public string Json.ReadString(string key);public static string SplashKit.JsonReadString(Json j, string key);
def json_read_string(j, key):
function JsonReadString(j: Json; key: String): String
Usage: {</>}
Adds an array of String
values to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Vector | The value to be inserted into the Json object. |
Signatures:
void json_set_array(json j, string key, vector<string> value)
public void Json.AddArray(string key, List<string> value);public static void SplashKit.JsonSetArray(Json j, string key, List<string> value);
def json_set_array_of_string(j, key, value):
procedure JsonSetArray(j: Json; key: String; value: ArrayOfString)
Usage: {</>}
Adds an array of Double
values to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Vector | The value to be inserted into the Json object. |
Signatures:
void json_set_array(json j, string key, vector<double> value)
public void Json.AddArray(string key, List<double> value);public static void SplashKit.JsonSetArray(Json j, string key, List<double> value);
def json_set_array_of_double(j, key, value):
procedure JsonSetArray(j: Json; key: String; value: ArrayOfDouble)
Adds an array of Boolean
values to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Vector | The value to be inserted into the Json object. |
Signatures:
void json_set_array(json j, string key, vector<bool> value)
public void Json.AddArray(string key, List<bool> value);public static void SplashKit.JsonSetArray(Json j, string key, List<bool> value);
def json_set_array_of_bool(j, key, value):
procedure JsonSetArray(j: Json; key: String; value: ArrayOfBoolean)
Adds an array of Json
object values to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Vector | The value to be inserted into the Json object. |
Signatures:
void json_set_array(json j, string key, vector<json> value)
public void Json.AddArray(string key, List<Json> value);public static void SplashKit.JsonSetArray(Json j, string key, List<Json> value);
def json_set_array_of_json(j, key, value):
procedure JsonSetArray(j: Json; key: String; value: ArrayOfJson)
Adds a Boolean
value to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Boolean | The value to be inserted into the Json object. |
Signatures:
void json_set_bool(json j, string key, bool value)
public void Json.AddBool(string key, bool value);public static void SplashKit.JsonSetBool(Json j, string key, bool value);
def json_set_bool(j, key, value):
procedure JsonSetBool(j: Json; key: String; value: Boolean)
Usage: {</>}
Adds an Integer
value to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Integer | The value to be inserted into the Json object. |
Signatures:
void json_set_number(json j, string key, int value)
public void Json.AddNumber(string key, int value);public static void SplashKit.JsonSetNumber(Json j, string key, int value);
def json_set_number_integer(j, key, value):
procedure JsonSetNumber(j: Json; key: String; value: Integer)
Usage: {</>}
Adds a Double
value to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Double | The value to be inserted into the Json object. |
Signatures:
void json_set_number(json j, string key, double value)
public void Json.AddNumber(string key, double value);public static void SplashKit.JsonSetNumber(Json j, string key, double value);
def json_set_number_double(j, key, value):
procedure JsonSetNumber(j: Json; key: String; value: Double)
Adds a Float
value to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | Float | The value to be inserted into the Json object. |
Signatures:
void json_set_number(json j, string key, float value)
public void Json.AddNumber(string key, float value);public static void SplashKit.JsonSetNumber(Json j, string key, float value);
def json_set_number_float(j, key, value):
procedure JsonSetNumber(j: Json; key: String; value: Single)
Adds a Json
object to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
obj | Json | The value to be inserted into the Json object. |
Signatures:
void json_set_object(json j, string key, json obj)
public void Json.AddObject(string key, Json obj);public static void SplashKit.JsonSetObject(Json j, string key, Json obj);
def json_set_object(j, key, obj):
procedure JsonSetObject(j: Json; key: String; obj: Json)
Usage: {</>}
Adds a String
value to the Json
object for the given String
key.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object where data will be inserted for the given key. |
key | String | The String key where data will be stored in the Json object. |
value | String | The value to be inserted into the Json object. |
Signatures:
void json_set_string(json j, string key, string value)
public void Json.AddString(string key, string value);public static void SplashKit.JsonSetString(Json j, string key, string value);
def json_set_string(j, key, value):
procedure JsonSetString(j: Json; key: String; value: String)
Usage: {</>}
Converts a Json
object to a Color
object.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json to convert to a Color . |
Return Type: Color
Signatures:
color json_to_color(json j)
public static Color SplashKit.JsonToColor(Json j);
def json_to_color(j):
function JsonToColor(j: Json): Color
Writes the Json
object to a JSON string stored in Resources/json/filename
.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object to be written to file. |
filename | String | The filename of the file to be stored in Resources/json/ |
Signatures:
void json_to_file(json j, const string &filename)
public static void Json.ToFile(Json j, string filename);public static void SplashKit.JsonToFile(Json j, string filename);
def json_to_file(j, filename):
procedure JsonToFile(j: Json; const filename: String)
Usage: {</>}
Converts and returns the Json
object as a String
.
Parameters:
Name | Type | Description |
---|---|---|
j | Json | The Json object to be converted to a String . |
Return Type: String
Signatures:
string json_to_string(json j)
public static string Json.ToJsonString(Json j);public static string SplashKit.JsonToString(Json j);
def json_to_string(j):
function JsonToString(j: Json): String
The Json
type is used to refer to objects in the JSON format that can be
manipulated by the SplashKit Json
functions and procedures.
All Json
objects are:
-
created with
create_json()
orcreate_json(string s)
orjson_from_string(string s)
orjson_from_file(json j)
-
and must be released using
free_json()
(to release a specificJson
object) orfree_all_json()
(to release all loadedJson
objects).