cf_JSONrecord ( fieldList ; JSON )
This will take a record and recursively create the field and contents as a JSON object.
Average rating: 5.0 (1 vote) Log in to vote
Jason Lecureux - Show more from this author |
cf_JSONrecord ( FieldNames ( "File Name"; "Layout Name" ); "" )
{"field1": data,"field2": data,"field3": "data","field4": "data"}
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
You will also need the "Supertrim" custom function or some other way to remove the "\r" after the field name. (UPDATE: I've had better success with the Trim4 cf)
The "FieldNames" function pairs nicely if you want all the fields for a given record. Keep in mind this uses a layout to gather field names. If a field you want is in the table but not on the layout it won't show up.
This hasn't been tested with portal data.
Comments
belg4mit Aug 19, 2022 |
||
Using SetElement's default variable type does not work for numerous field types including containers and fields with repetitions.; the latter would be best represented by an array. | ||
Jason Lecureux Aug 22, 2022 |
||
Thank you for the response @belg4mit. I can't comment on the plausibility of having compatibility for those fields types. That is beyond my capabilities. | ||
Kevin B May 19, 2023 |
||
Hi there--Can you give me another example of the sample input? Is it just the field names separated by a comma? Thanks! | ||
Jason Lecureux Oct 20, 2023 |
||
Hey Kevin, it's just looking for a list not comma separated fields. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.