// Jasic JSON (JavaScript Object Notation) string manipulation from C
// This is an efficient thing to do in javascript but not really in C, but allow some access from C anyway

#ifndef JSON_HEADER
#define JSON_HEADER

#include <stddef.h>
#include "lib.h"

char *json_basicvalue(char *json, char *field, char *bf);

char *json_object_getfield(char *obj, char *field, char *bf);
int json_object_setfield(char *obj, char *field, char *value, char *out);
int json_object_setfield_object(char *obj, char *field, char *value, char *real_out);

int json_array_length(char *arr);
char *json_array_item(char *arr, int item, char *obj);
char *json_array_append(char *arr, char *obj, char *out);

int json_validate(char **s, int depth);	// Recursive routine to validate a string
int json_validate_plainstring(char *s);
int isjson(char *);

int json_email_array_wash(char*src, char *dest, int bfsz);


char* json_validate2(char*p1, char*result, int bfsz);
char* json_validate2_bool(char*p1, char*result, int bfsz);
char* json_validate_bool(char*p1);
int json_blank(char*p1);

void json_object_getbool(char *obj, char *field, int *result);
char* json_validate_int(char*p1, char*result, int bfsz);


#endif

