Oyranos  0.9.7
Oyranos is a full featured Color Management System
Functions
oyjl_tree.c File Reference

A easy to use JSON parsing API. More...

#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>
#include "oyjl_tree.h"
#include "oyjl_tree_internal.h"

Functions

oyjl_val oyjl_tree_parse (const char *input, char *error_buffer, size_t error_buffer_size)
 read a json text string into a C data structure More...
 
char * oyjl_value_text (oyjl_val v, void *(*alloc)(size_t size))
 get the value as text string with user allocator More...
 
void oyjl_tree_to_paths (oyjl_val root, int levels, const char *xpath, int flags, char ***paths)
 find matching paths More...
 
void oyjl_tree_to_json (oyjl_val v, int *level, char **json)
 convert a C tree into a JSON string More...
 
int oyjl_value_count (oyjl_val v)
 return the number of members if any at the node level More...
 
oyjl_val oyjl_value_pos_get (oyjl_val v, int pos)
 obtain a child node at the nth position from a object or array node More...
 
int oyjl_path_match (const char *path, const char *xpath)
 search for xpath pattern matching in a full path More...
 
oyjl_val oyjl_tree_new (const char *xpath)
 create a node by a path expression More...
 
oyjl_val oyjl_tree_get_value (oyjl_val v, int flags, const char *xpath)
 obtain a node by a path expression More...
 
oyjl_val oyjl_tree_get_valuef (oyjl_val v, int flags, const char *format,...)
 get a child node by a path expression More...
 
int oyjl_value_set_string (oyjl_val v, const char *string)
 set the node value to a string More...
 
void oyjl_value_clear (oyjl_val v)
 release all childs recursively More...
 
void oyjl_tree_clear_value (oyjl_val root, const char *xpath)
 release a specific node and all its childs More...
 
void oyjl_tree_free (oyjl_val v)
 release a node and all its childs recursively More...
 

Detailed Description

A easy to use JSON parsing API.

Here comes a minimalistic example:

oyjl_val root = 0;
char error_buffer[128];
root = oyjl_tree_parse( text, error_buffer, 128 );
char * json = 0;
int level = 0;
oyjl_tree_to_json( root, &level, &json );