--- libelwix/src/json.c 2017/11/28 00:46:53 1.1.2.4 +++ libelwix/src/json.c 2017/11/28 02:00:45 1.1.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: json.c,v 1.1.2.4 2017/11/28 00:46:53 misho Exp $ +* $Id: json.c,v 1.1.2.5 2017/11/28 02:00:45 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -536,7 +536,7 @@ json_token2array(const char *jstr, jtok_t * __restrict return NULL; siz = tok->tok_size; - if (!siz && tok->tok_type != J_ARRAY && tok->tok_type != J_OBJECT) + if (!siz && json_toktype(tok) != J_ARRAY && json_toktype(tok) != J_OBJECT) siz++; arr = ait_allocVars(siz); @@ -545,14 +545,14 @@ json_token2array(const char *jstr, jtok_t * __restrict if (tok->tok_type == J_STRING || tok->tok_type == J_VALUE) { v = ait_getVars(&arr, 0); - AIT_SET_STRSIZ(v, tok->tok_end - tok->tok_start); - strncpy(AIT_GET_STR(v), jstr + tok->tok_start, AIT_LEN(v) - 1); + AIT_SET_STRSIZ(v, json_toklen(tok)); + json_tokstrcpy(AIT_GET_STR(v), jstr, tok); } else if (tok->tok_type == J_ARRAY) { for (i = 0; i < tok->tok_size; i++) { t = &tok[i + 1]; v = ait_getVars(&arr, i); - AIT_SET_STRSIZ(v, t->tok_end - t->tok_start); - strncpy(AIT_GET_STR(v), jstr + t->tok_start, AIT_LEN(v) - 1); + AIT_SET_STRSIZ(v, json_toklen(t)); + json_tokstrcpy(AIT_GET_STR(v), jstr, t); } } else { /* todo for object */