Simple JSON
0.1
A free simple json library for C
|
#include "simple_json_list.h"
#include "simple_json_array.h"
#include "simple_json_string.h"
#include "simple_json_object.h"
#include "simple_json_error.h"
Go to the source code of this file.
Functions | |
void | sj_free (SJson *sjs) |
frees a previously loaded json struct More... | |
SJson * | sj_copy (SJson *json) |
make a duplicate of a json structure. More... | |
SJson * | sj_load (const char *filename) |
loads and parses a json file More... | |
void | sj_save (SJson *json, char *filename) |
write a json value as a formatted json string to file More... | |
SJson * | sj_new_str (char *str) |
make a new json value that is a string More... | |
const char * | sj_get_string_value (SJson *json) |
get the JSON value as a string More... | |
int | sj_get_integer_value (SJson *json, int *i) |
get the json value as an integer Can be used to check for existence More... | |
int | sj_get_float_value (SJson *json, float *f) |
get the json value as a float Can be used to check for existence More... | |
int | sj_get_bool_value (SJson *json, short int *b) |
get the json value as a bool Can be used to check for existence More... | |
SJson * | sj_new_int (int i) |
make a new json value that is an integer More... | |
SJson * | sj_new_float (float f) |
make a new json value that is a float More... | |
SJson * | sj_new_bool (int b) |
make a new json value that is a bool More... | |
SJson * | sj_null_new () |
make a new json value that is NULL More... | |
SJson * | sj_object_new () |
allocate a new empty json object More... | |
void | sj_object_insert (SJson *object, char *key, SJson *value) |
insert data into a json object More... | |
SJson * | sj_object_get_value (SJson *object, char *key) |
get the json value from an object given a key More... | |
SJson * | sj_array_new () |
allocate a new empty json array More... | |
void | sj_array_append (SJson *array, SJson *value) |
append to a JSON array a new value More... | |
int | sj_array_get_count (SJson *array) |
get the number of elements in the json array More... | |
SJson * | sj_array_get_nth (SJson *array, int n) |
retrieve the nth element in the json array More... | |
void | sj_echo (SJson *json) |
print the contents of the json file to stdout More... | |
int | sj_is_array (SJson *json) |
check if the json is an array More... | |
int | sj_is_object (SJson *json) |
check if the json is an object More... | |
int | sj_is_string (SJson *json) |
check if the json is a string More... | |
int | sj_is_number (SJson *json) |
check if the json is a number More... | |
int | sj_is_bool (SJson *json) |
check if the json is a bool More... | |
int | sj_is_null (SJson *json) |
check if the json is NULL More... | |
append to a JSON array a new value
array | the JSON array to append to |
value | the value to add to the string |
Definition at line 72 of file simple_json_array.c.
int sj_array_get_count | ( | SJson * | array | ) |
get the number of elements in the json array
array | the json array |
Definition at line 66 of file simple_json_array.c.
retrieve the nth element in the json array
array | the array to search through |
n | the index of the element to get |
Definition at line 79 of file simple_json_array.c.
SJson* sj_array_new | ( | ) |
allocate a new empty json array
Definition at line 38 of file simple_json_array.c.
make a duplicate of a json structure.
json | the json to be duplicated |
Definition at line 109 of file simple_json.c.
void sj_echo | ( | SJson * | json | ) |
print the contents of the json file to stdout
json | the json struct to print |
Definition at line 140 of file simple_json.c.
void sj_free | ( | SJson * | sjs | ) |
frees a previously loaded json struct
Definition at line 116 of file simple_json.c.
int sj_get_bool_value | ( | SJson * | json, |
short int * | b | ||
) |
get the json value as a bool Can be used to check for existence
json | the json value to get from |
b | [optional] place to write the output to |
Definition at line 202 of file simple_json.c.
int sj_get_float_value | ( | SJson * | json, |
float * | f | ||
) |
get the json value as a float Can be used to check for existence
json | the json value to get from |
f | [optional] place to write the output to |
Definition at line 196 of file simple_json.c.
int sj_get_integer_value | ( | SJson * | json, |
int * | i | ||
) |
get the json value as an integer Can be used to check for existence
json | the json value to get from |
i | [optional] place to write the output to |
Definition at line 190 of file simple_json.c.
const char* sj_get_string_value | ( | SJson * | json | ) |
get the JSON value as a string
json | the json value to get the string from |
Definition at line 184 of file simple_json.c.
int sj_is_array | ( | SJson * | json | ) |
check if the json is an array
json | the json to check |
Definition at line 208 of file simple_json.c.
int sj_is_bool | ( | SJson * | json | ) |
check if the json is a bool
json | the json to check |
Definition at line 236 of file simple_json.c.
int sj_is_null | ( | SJson * | json | ) |
check if the json is NULL
json | the json to check |
Definition at line 243 of file simple_json.c.
int sj_is_number | ( | SJson * | json | ) |
check if the json is a number
json | the json to check |
Definition at line 229 of file simple_json.c.
int sj_is_object | ( | SJson * | json | ) |
check if the json is an object
json | the json to check |
Definition at line 215 of file simple_json.c.
int sj_is_string | ( | SJson * | json | ) |
check if the json is a string
json | the json to check |
Definition at line 222 of file simple_json.c.
SJson* sj_load | ( | const char * | filename | ) |
loads and parses a json file
filename | the file to parse |
Definition at line 47 of file simple_json.c.
SJson* sj_new_bool | ( | int | b | ) |
make a new json value that is a bool
b | the boolean value (1 is true, 0 is false) |
Definition at line 24 of file simple_json.c.
SJson* sj_new_float | ( | float | f | ) |
make a new json value that is a float
f | the float value |
Definition at line 19 of file simple_json.c.
SJson* sj_new_int | ( | int | i | ) |
make a new json value that is an integer
i | the integer value |
Definition at line 14 of file simple_json.c.
SJson* sj_new_str | ( | char * | str | ) |
make a new json value that is a string
str | the string to base the json value on |
Definition at line 9 of file simple_json.c.
SJson* sj_null_new | ( | ) |
make a new json value that is NULL
Definition at line 173 of file simple_json.c.
get the json value from an object given a key
object | the hson object to get |
key | the key to search by |
Definition at line 116 of file simple_json_object.c.
insert data into a json object
object | the json object to insert into |
key | the string to identify the object value with |
value | the value of the key |
Definition at line 58 of file simple_json_object.c.
SJson* sj_object_new | ( | ) |
allocate a new empty json object
Definition at line 87 of file simple_json_object.c.
void sj_save | ( | SJson * | json, |
char * | filename | ||
) |
write a json value as a formatted json string to file
json | the struct to convert and write |
filename | the file to overwrite |
Definition at line 123 of file simple_json.c.