Simple JSON  0.1
A free simple json library for C
simple_json_array.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "simple_json.h"
#include "simple_json_list.h"
#include "simple_json_array.h"
#include "simple_json_error.h"
Include dependency graph for simple_json_array.c:

Go to the source code of this file.

Functions

int sj_array_check (SJson *json)
 
SJsonsj_array_copy (SJson *json)
 
SJsonsj_array_new ()
 allocate a new empty json array More...
 
void sj_array_free (SJson *array)
 
int sj_array_get_count (SJson *array)
 get the number of elements in the json array More...
 
void sj_array_append (SJson *array, SJson *value)
 append to a JSON array a new value More...
 
SJsonsj_array_get_nth (SJson *array, int n)
 retrieve the nth element in the json array More...
 
SJStringsj_array_get_nth_as_string (SJson *array, int n)
 retrieve the nth element in the json array assumed to be a string More...
 
SJStringsj_array_to_json_string (SJson *array)
 get the contents of the array as a formatted json string for output More...
 

Function Documentation

void sj_array_append ( SJson array,
SJson value 
)

append to a JSON array a new value

Parameters
arraythe JSON array to append to
valuethe value to add to the string
Note
: this is a no-op if array is not an actual JSON array

Definition at line 72 of file simple_json_array.c.

int sj_array_check ( SJson json)

Definition at line 9 of file simple_json_array.c.

SJson* sj_array_copy ( SJson json)

Definition at line 20 of file simple_json_array.c.

void sj_array_free ( SJson array)

Definition at line 51 of file simple_json_array.c.

int sj_array_get_count ( SJson array)

get the number of elements in the json array

Parameters
arraythe json array
Returns
0 if there is an error, the count otherwise

Definition at line 66 of file simple_json_array.c.

SJson* sj_array_get_nth ( SJson array,
int  n 
)

retrieve the nth element in the json array

Parameters
arraythe array to search through
nthe index of the element to get
Returns
NULL on error (check sj_get_error()) or the SJson value otherwise

Definition at line 79 of file simple_json_array.c.

SJString* sj_array_get_nth_as_string ( SJson array,
int  n 
)

retrieve the nth element in the json array assumed to be a string

Parameters
arraythe array to search through
nthe index of the element to get
Returns
NULL on error (check sj_get_error()) or the SJString value otherwise

Definition at line 85 of file simple_json_array.c.

SJson* sj_array_new ( )

allocate a new empty json array

Returns
NULL on memory allocation error, an empty SJson array otherwise

Definition at line 38 of file simple_json_array.c.

SJString* sj_array_to_json_string ( SJson array)

get the contents of the array as a formatted json string for output

Parameters
arraythe json array to convert
Returns
a formatted json character array "[*,*,....]"

Definition at line 95 of file simple_json_array.c.