|
version 1.11, 2024/12/04 17:47:28
|
version 1.12, 2025/08/21 15:43:00
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004 - 2024 | Copyright 2004 - 2025 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 597 json_findbykey(const char *jstr, const char *key, jtyp
|
Line 597 json_findbykey(const char *jstr, const char *key, jtyp
|
| * @type = Search key for particular token type, if is J_UNDEF this mean any type |
* @type = Search key for particular token type, if is J_UNDEF this mean any type |
| * @toks = Parsed tokens |
* @toks = Parsed tokens |
| * @toksnum = Number of parsed tokens |
* @toksnum = Number of parsed tokens |
| * return: =NULL error or !=NULL data token found | * return: =NULL error or !=NULL data token found |
| */ |
*/ |
| jtok_t * |
jtok_t * |
| json_findbykeyatscope(long scope, const char *jstr, const char *key, jtype_t type, jtok_t * __restrict toks, int toksnum) |
json_findbykeyatscope(long scope, const char *jstr, const char *key, jtype_t type, jtok_t * __restrict toks, int toksnum) |
|
Line 1325 json_objscope(const char *key, const char *jstr, jtok_
|
Line 1325 json_objscope(const char *key, const char *jstr, jtok_
|
| } |
} |
| |
|
| return scope; |
return scope; |
| |
} |
| |
|
| |
/* |
| |
* json_validate() - Validate JSON |
| |
* |
| |
* @jstr = JSON string |
| |
* return: -1 error or >=0 where valid JSON ends |
| |
*/ |
| |
int |
| |
json_validate(const char *jstr) |
| |
{ |
| |
register int o = 0, a = 0, pos = 0; |
| |
|
| |
while (isspace(jstr[pos]) || jstr[pos] != '{') |
| |
pos++; |
| |
|
| |
do { |
| |
switch (jstr[pos++]) { |
| |
case '{': |
| |
o++; |
| |
break; |
| |
case '}': |
| |
o--; |
| |
break; |
| |
case '[': |
| |
a++; |
| |
break; |
| |
case ']': |
| |
a--; |
| |
break; |
| |
case 0: /* string ends without valid JSON */ |
| |
return 0; |
| |
} |
| |
} while (a || o); |
| |
|
| |
return pos; |
| } |
} |