NEWS: Welcome to my new homepage! <3

libjson.h - libjson - A simple JSON parser

libjson

A simple JSON parser
git clone git://192.168.2.2/libjson
Log | Files | Refs | README

libjson.h (632B)


      1 #pragma once
      2 
      3 #include <jsmn.h>
      4 
      5 typedef enum {
      6   JSON_OK = 0,
      7   JSON_ERR_INVALID_TYPE = 1,
      8   JSON_ERR_INVALID_SIZE = 2,
      9   JSON_ERR_INVALID_FORMAT = 3,
     10   JSON_ERR_INVALID_MISSING = 4,
     11 } json_err_t;
     12 
     13 typedef struct {
     14   jsmntok_t *tokens;
     15   int len;
     16   int ptr;
     17   const char *str;
     18   json_err_t err;
     19 } json_ptr_t;
     20 
     21 char *json_str(json_ptr_t json_ptr);
     22 int json_size(json_ptr_t json_ptr);
     23 json_ptr_t json_parse(jsmntok_t tokens[], int tokens_len, const char *str);
     24 json_ptr_t json_get(json_ptr_t json_ptr, const char *key);
     25 json_ptr_t json_at(json_ptr_t json_ptr, int idx);
     26 json_ptr_t json_query(json_ptr_t json_ptr, const char *query);