jsonparse
function jsonparse(afct:array(range) of string|function,ctx:ctxtype): integer
afct
|
Event function table. Each entry of this array is the name of or a reference to the function to call when the corresponding event occurs. The expected events are (all of these entries are optional):
|
||||||||||||||||
ctx
|
Value passed as firt argument of all event functions
|
declarations afct:array(range) of string s_ctx=record cnt:integer end-record c:s_ctx end-declarations public function setvalue_all(ctx:s_ctx,name:text,type:integer,val:text):integer if name="name" or name="age" then writeln(name,":",val) ctx.cnt+=1 end-if end-function afct(JSON_FCT_TEXT):="setvalue_all" ! A value as a text fopen("mydoc.json",F_INPUT) rts:=jsonparse(afct,c) fclose(F_INPUT) writeln("line count:",c.cnt)
- JSON_FCT_OPEN_OBJ
- function open_object(ctx:ctxtype, name:text):integer
- JSON_FCT_CLOSE_OBJ
- function close_object(ctx:ctxtype):integer
- JSON_FCT_OPEN_ARR
- function open_array(ctx:ctxtype, name:text):integer
- JSON_FCT_CLOSE_ARR
- function close_array(ctx:ctxtype):integer
- JSON_FCT_TEXT
- function text_val(ctx:ctxtype, name:text, type:integer, val:text):integer
- JSON_FCT_NUM
- function num_val(ctx:ctxtype, name:text, val:real):integer
- JSON_FCT_BOOL
- function bool_val(ctx:ctxtype, name:text, val:boolean):integer
- JSON_FCT_NULL
- function null_val(ctx:ctxtype, name:text):integer
The name argument is not empty only when the value corresponds to an object member: in this case this parameter is the label of this member. The type argument passed to the text_val function indicates the type of the data (0 for null, 1 for text, 2 for numerical and 3 for Boolean): this function is used with the textual representation of the value when the required type-specific function is not available. For instance this function will be called with type=3 if a Boolean value has been read and the entry JSON_FCT_BOOL is not defined in the function table.
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.