JSON negative number patch
This commit is contained in:
parent
3c41a79102
commit
23e40384f7
4 changed files with 11 additions and 13 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
* When user callbacks such as statedata() call returns -1, clixon_backend no
|
* When user callbacks such as statedata() call returns -1, clixon_backend no
|
||||||
longer silently exits. Instead a log is printed and an RPC error is returned.
|
longer silently exits. Instead a log is printed and an RPC error is returned.
|
||||||
* Added Floating point support to JSON
|
* Added Floating point and negative number support to JSON
|
||||||
* Restconf: http cookie sent as attribute in rpc restconf_post operations to backend.
|
* Restconf: http cookie sent as attribute in rpc restconf_post operations to backend.
|
||||||
* Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to
|
* Added option CLICON_CLISPEC_FILE as complement to CLICON_CLISPEC_DIR to
|
||||||
specify single CLI specification file, not only directory containing files.
|
specify single CLI specification file, not only directory containing files.
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,7 @@ json_parse_str(char *str,
|
||||||
* Example compile:
|
* Example compile:
|
||||||
gcc -g -o json -I. -I../clixon ./clixon_json.c -lclixon -lcligen
|
gcc -g -o json -I. -I../clixon ./clixon_json.c -lclixon -lcligen
|
||||||
* Example run:
|
* Example run:
|
||||||
echo "" | xml
|
echo '{"foo": -23}' | ./json
|
||||||
*/
|
*/
|
||||||
#if 0 /* Test program */
|
#if 0 /* Test program */
|
||||||
|
|
||||||
|
|
@ -643,20 +643,17 @@ usage(char *argv0)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BUFLEN 1024 /* Size of xml read buffer */
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
cxobj *xt;
|
cxobj *xt;
|
||||||
cxobj *xc;
|
cxobj *xc;
|
||||||
cbuf *cb = cbuf_new();
|
cbuf *cb = cbuf_new();
|
||||||
int maxbuf = BUFLEN;
|
char *buf = NULL;
|
||||||
char *xmlbuf = NULL;
|
int i;
|
||||||
char *buf = NULL;
|
int c;
|
||||||
int i;
|
int len;
|
||||||
int c;
|
FILE *f = stdin;
|
||||||
int len;
|
|
||||||
FILE *f = stdin;
|
|
||||||
|
|
||||||
if (argc != 1){
|
if (argc != 1){
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
|
|
@ -689,7 +686,7 @@ main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
xc = NULL;
|
xc = NULL;
|
||||||
while ((xc = xml_child_each(xt, xc, -1)) != NULL) {
|
while ((xc = xml_child_each(xt, xc, -1)) != NULL) {
|
||||||
xmltree2cbuf(cb, xc, 0); /* dump data structures */
|
xmltree2cbuf(cb, xc, 0); /* dump data structures */
|
||||||
//clicon_xml2cbuf(cb, xc, 0, 1); /* print xml */
|
//clicon_xml2cbuf(cb, xc, 0, 1); /* print xml */
|
||||||
}
|
}
|
||||||
fprintf(stdout, "%s", cbuf_get(cb));
|
fprintf(stdout, "%s", cbuf_get(cb));
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ exp ({integer}|{real})[eE][+-]{integer}
|
||||||
<START>null { return J_NULL; }
|
<START>null { return J_NULL; }
|
||||||
<START>false { return J_FALSE; }
|
<START>false { return J_FALSE; }
|
||||||
<START>true { return J_TRUE; }
|
<START>true { return J_TRUE; }
|
||||||
<START>({integer}|{real}|{exp}) { clixon_json_parselval.string = strdup(yytext); return J_NUMBER;}
|
<START>\-?({integer}|{real}|{exp}) { clixon_json_parselval.string = strdup(yytext); return J_NUMBER;}
|
||||||
<START>. { return -1; }
|
<START>. { return -1; }
|
||||||
<STRING>\" { BEGIN(START); return J_DQ; }
|
<STRING>\" { BEGIN(START); return J_DQ; }
|
||||||
<STRING>\\ { BEGIN(ESCAPE); }
|
<STRING>\\ { BEGIN(ESCAPE); }
|
||||||
|
|
|
||||||
|
|
@ -1104,7 +1104,8 @@ xmltree2cbuf(cbuf *cb,
|
||||||
|
|
||||||
for (i=0; i<level*XML_INDENT; i++)
|
for (i=0; i<level*XML_INDENT; i++)
|
||||||
cprintf(cb, " ");
|
cprintf(cb, " ");
|
||||||
cprintf(cb, "%s", xml_type2str(xml_type(x)));
|
if (xml_type(x) != CX_BODY)
|
||||||
|
cprintf(cb, "%s", xml_type2str(xml_type(x)));
|
||||||
if (xml_namespace(x)==NULL)
|
if (xml_namespace(x)==NULL)
|
||||||
cprintf(cb, " %s", xml_name(x));
|
cprintf(cb, " %s", xml_name(x));
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue