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
Returns: Returns an empty Json object.
Signatures:
json create_json()public static Json SplashKit.CreateJson();public Json();def create_json():function CreateJson(): JsonUsage: {</>}
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
Returns: Returns a Json object filled with data from the parameter String.
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): JsonReleases 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:
Signatures:
void free_json(json j)public void Json.Free();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:
Return Type: Integer
Returns: The count of keys in the top-level Json object.
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): IntegerConverts a Color to a Json object.
Parameters:
Return Type: Json
Returns: The Color serialized into a Json object.
Signatures:
json json_from_color(color clr)public static Json SplashKit.JsonFromColor(Color clr);def json_from_color(clr):function JsonFromColor(clr: Color): JsonReads 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
Returns: Returns the Json object loaded from the JSON file in filename.
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): JsonUsage: {</>}
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
Returns: Returns a Json object loaded with data from string j_string.
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): JsonUsage: {</>}
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
Returns: Returns true if the json j object contains a key for String key.
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): BooleanUsage: {</>}
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
Returns: Returns the Boolean value stored at the String key.
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): BooleanReads 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
Returns: Returns the Float value stored at the String key.
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): SingleReads 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
Returns: Returns the Double value stored at the String key.
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): DoubleReads 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
Returns: Returns the integer value stored at the String key.
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): IntegerUsage: {</>}
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
Returns: Returns the Json object value stored at the String key.
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): JsonUsage: {</>}
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
Returns: Returns the String value stored at the String key.
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): StringUsage: {</>}
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:
Return Type: Color
Returns: The Color deserialized from the Json object.
Signatures:
color json_to_color(json j)public static Color SplashKit.JsonToColor(Json j);def json_to_color(j):function JsonToColor(j: Json): ColorWrites 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:
Return Type: String
Returns: Returns the Json object as a 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): StringThe 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 specificJsonobject) orfree_all_json()(to release all loadedJsonobjects).