フィールド名を key として、1レコード分のデータを json として取得。
除外フィールド:計算,集計,オブジェクト,グローバル
FileMaker Pro 18 以降
フィールドが繰り返しの場合、JSON 配列になります。
戻り値 例:
{"Field01":"Value01","Field02":["Repetition01","Repetition02","Repetition03"]}
フィールド名を key として、1レコード分のデータを json として取得。
除外フィールド:計算,集計,オブジェクト,グローバル
FileMaker Pro 18 以降
フィールドが繰り返しの場合、JSON 配列になります。
戻り値 例:
{"Field01":"Value01","Field02":["Repetition01","Repetition02","Repetition03"]}
Let (
[
~query = "select
'[\"'||TableName ||'::'||FieldName||'\"'
,''||''||FieldReps||']'
FROM FILEMAKER_FIELDS
WHERE
TableName ='{TableName}'
AND
FieldClass = 'Normal'
AND
FieldType NOT LIKE 'global%' /*除外 グローバルフィールド*/
AND
FieldType <> 'binary' /*除外 オブジェクトフィールド*/
"
;~query=Substitute ( ~query ; "{TableName}" ; TableName )
;~FieldNames = ExecuteSQL ( ~query ; "," ; "" )
];
While (
[
~json=""
;~MAX = ValueCount ( ~FieldNames )
;~n= 1
] ;
~n <= ~MAX ;
[
~Array=GetValue ( ~FieldNames ; ~n )
;~FieldName=JSONGetElement(~Array;0)
;~FieldReps=JSONGetElement(~Array;1)
;~key = GetValue ( Substitute ( ~FieldName ; "::" ; ¶ ) ; 2 )
;~json = If(~FieldReps=1;
JSONSetElement ( ~json ; ~key ; GetField ( ~FieldName ) ; JSONString)
;
JSONSetElement ( ~json ; ~key ;
While (
[
~RepsData=""
;~i = 1
;~index=0
];
~i<=~FieldReps;
[
~RepsData=JSONSetElement (~RepsData ; "[" &~index & "]" ; GetField ( ~FieldName & "["&~i &"]" ) ;JSONString)
;~i =~i+ 1
;~index=~index+1
];
~RepsData
)
; JSONArray)
)//if
;~n=~n+1
] ;
~json
)
)