@ brief Helper functions to parse a JSON string in C.
Created on: Apr 14, 2018 Author: Delengowski & Szymczak
char* json_find_key |
( |
char * |
key, |
|
|
char * |
json |
|
) |
| |
Parses a JSON string for the string pointed to by key.
- Author
- Matt Delengowksi
- Date
- Apr 14, 2018
- Parameters
-
key | A pointer to a string that is a key within a JSON string |
json | A pointer to the JSON string for which to parse for keys |
- Returns
- Returns the location of the first '[' after the key has been found in json
char* json_find_list_item |
( |
uint16_t |
number, |
|
|
char * |
json |
|
) |
| |
for finding the nth list item in the json key
- Parameters
-
number | The nth list item in the json key |
json | The json key being passed in |
- Returns
- returns a char pointer, pointing to the nth list item in the json key
unsigned int json_get_int |
( |
char * |
json | ) |
|
This function gets the integer associated with a list item from a JSON string.
- Author
- Stephen Szymczak
- Date
- Apr 14, 2018 This function goes through a json string until a ' : ' is found, then checks for and skips spaces. It is assumed the next value after either ':' or ' ' will be a number. The function gets the number. Only unsigned ints are valid (0-65535).
- Parameters
-
json | A pointer to the JSON string for which to parse for numbers. |
- Returns
- Returns the integer associated with JSON string in question.
void json_get_string |
( |
char * |
json, |
|
|
char * |
mystring |
|
) |
| |
This function gets the string associated with a list item from a JSON string.
- Author
- Stephen Szymczak
- Date
- Apr 14, 2018 This function goes through a json string until a ' : ' is found, then gets the string following the list item, parsing out the ' " ' at beginning and end. Fills a character array with the desired string.
- Parameters
-
json | A pointer to the JSON string for which to parse for the string. |
mystring | A pointer to a user defined string which is populated with the string extraced from json |