libjapi
0.3.2
Universal JSON API Library
|
Universal JAPI helper functions library. More...
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <json-c/json.h>
#include "japi_utils.h"
Functions | |
int | japi_get_value_as_str (json_object *jobj, const char *key, const char **val) |
Get string value from json key. More... | |
int | japi_get_value_as_bool (json_object *jobj, const char *key, bool *val) |
Get boolean value from json key. More... | |
int | japi_get_value_as_int (json_object *jobj, const char *key, int *val) |
Get int value from json key. More... | |
int | japi_get_value_as_int64 (json_object *jobj, const char *key, long long int *val) |
Get int64 value from json key. More... | |
int | japi_get_value_as_double (json_object *jobj, const char *key, double *val) |
Get double value from json key. More... | |
char * | japi_get_jobj_as_ndstr (json_object *jobj) |
Returns a string with added newline. More... | |
Universal JAPI helper functions library.
japi_utils is a universal JSON API helper library.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
char* japi_get_jobj_as_ndstr | ( | json_object * | jobj | ) |
Returns a string with added newline.
Stringify the JSON object, copy it to a new allocated buffer and append a newline. This is necessary to ensure that a call to write() will send the message at once, meaning the message and the newline are not separated in two strings. The caller is responsible for freeing the returned string.
jobj | The JSON object |
Referenced by japi_process_message(), and japi_pushsrv_sendmsg().
int japi_get_value_as_bool | ( | json_object * | jobj, |
const char * | key, | ||
bool * | val | ||
) |
Get boolean value from json key.
Return boolean for the given json key.
jobj | The json-object to parse |
key | The corresponding key to requested value |
val | The requested value |
int japi_get_value_as_double | ( | json_object * | jobj, |
const char * | key, | ||
double * | val | ||
) |
Get double value from json key.
Return double for the given json key.
jobj | The json-object to parse |
key | The corresponding key to requested value |
val | The requested value |
int japi_get_value_as_int | ( | json_object * | jobj, |
const char * | key, | ||
int * | val | ||
) |
Get int value from json key.
Return int for the given json key.
jobj | The json-object to parse |
key | The corresponding key to requested value |
val | The requested value |
int japi_get_value_as_int64 | ( | json_object * | jobj, |
const char * | key, | ||
long long int * | val | ||
) |
Get int64 value from json key.
Return int64 for the given json key.
jobj | The json-object to parse |
key | The corresponding key to requested value |
val | The requested value |
int japi_get_value_as_str | ( | json_object * | jobj, |
const char * | key, | ||
const char ** | val | ||
) |
Get string value from json key.
Return string for the given json key.
jobj | The json-object to parse |
key | The corresponding key to requested value |
val | The requested value |
Referenced by japi_process_message().