46 if(line == NULL)
return -1;
47 if(record == NULL)
return -1;
51 while(line[i] ==
' ') i++;
61 char *start = text.
text();
62 char *end = strchr(start,
'"');
69 start = strchr(start,
'"');
73 end = strchr(start,
'"');
77 record->
param = start;
93 if(strchr(line,
'.') != NULL)
96 record->
param = &line[i];
98 cptr = strchr(cptr,
',');
99 if(cptr != NULL) *cptr =
'\0';
103 if(line[i] >=
'0' && line[i] <=
'9') record->
optParamType = 1;
108 cptr = strchr(cptr,
',');
109 if(cptr != NULL) *cptr =
'\0';
113 if(strchr(line,
':') != NULL) record->
optColon = 1;
116 if(strchr(line,
',') != NULL) record->
optComma = 1;
123 if(record == NULL)
return -1;
124 if(indent != NULL) printf(
"%s",indent);
127 fprintf(fout,
"\"%s\"",record->
text.
text());
134 else fprintf(fout,
"%s",record->
param.
text());
135 if(record->
optComma == 1) fprintf(fout,
",");
140 if(record->
optComma == 1) fprintf(fout,
",");
146 if(record->
optColon == 1) fprintf(fout,
":");
149 else fprintf(fout,
"%s",record->
param.
text());
155 if(record->
optColon == 1) fprintf(fout,
":");
156 fprintf(fout,
" [\n");
167 if(record->
optComma == 1) fprintf(fout,
",");
173 if(record->
optComma == 1) fprintf(fout,
",");
183 printf(
"Test rljson begin:\n");
187 printf(
"rljson.initRecord ret=%d\n", ret);
201 printf(
"optColon=%d\n", record.
optColon);
204 printf(
"optComma=%d\n", record.
optComma);
205 printf(
"optParamType=%d (0=default=text 1=integer 2=float)\n", record.
optParamType);
207 rljson.
print(stdout,&record);
208 printf(
"rljson.print ret=%d\n", ret);
210 FILE *fin = fopen(
"/home/lehrig/temp/json1.txt",
"r");
213 printf(
"could not open /home/lehrig/temp/json1.txt\n");
218 while(fgets(line,1023,fin) != NULL)
220 printf(
"json1.txt: %s", line);
222 printf(
"DEBUG: text=%s param=%s withText=%d\n" 223 "startsWith: openBracket=%d closeBracket=%d endArray=%d\n" 224 "opt: colon=%d openBracket=%d beginArray=%d paramType=%d comma=%d\n",
int print(FILE *fout, rlJSONrecord *record, const char *indent="")
int interpret(const char *line, rlJSONrecord *record)
int startsWithOpenBracket
int setText(const char *text)
int startsWithCloseBracket
int initRecord(rlJSONrecord *record)