JSON Module, and setting Table/Row/Field values

78 views
Skip to first unread message

Gary Wong

unread,
May 19, 2015, 5:10:21 PM5/19/15
to modular-...@googlegroups.com
First off, much thx to Modular devs for doing this, and sharing your work.  I've installed #Parameters and JSON, and got the "Insert from URL" working great. 

Data::letNotation successfully gets the parsed content:
"$site_id = \"CR-1004\" ;¶$structure_id = \"CR-1004\" ;¶$crossing_name = \"Amai Creek\" ;¶"
"$site_id = \"CR-1006\" ;¶$structure_id = \"CR-1006\" ;¶$crossing_name = \"Ray Creek\" ;¶"

Is there a way to "Evaluate" each row to set the Fields in the database?  I've tried simply to set local variables to the JSON parsed line:
Set Variable [$!; Evaluate ( "Let ( [" & $DataRow & "] ;"  )]

Where $DataRow is, for test purposes:
"$site_id = \"CR-9999\" ;¶$structure_id = \"CR-9999\" ;¶$crossing_name = \"Ganges River\" ;¶"

But I cannot even set a local variable to be dynamically set from the JSON parsed content.  Am I missing an obvious JSON Module function to do this just this?  If not, I supposed I'll have to loop through each row and do a 'Set Field by Name" on each variable.

TIA
Gary

Jeremy Bante

unread,
May 19, 2015, 5:31:17 PM5/19/15
to modular-...@googlegroups.com
The return-delimited list format that the JSON module converts arrays to is not the most intuitive thing in the world. (I personally prefer variable arrays to return-delimited lists, but that doesn't help here.) To pull out each row, simply do:

Set Variable [$row; Evaluate ( GetValue ( $parsedContent ; $rowNumber ) )]

Then to set the $row data to variables:

Set Variable [$errorCode; EvaluationError ( Evaluate ( "Let ( [" & $row & " _ = \"\" ] ; \"\" )" ) )]

There are also dedicated custom functions for this in the #Parameters module:

Set Variable [$ignoreMe; #Assign ( #ListGet ( $parsedContent ; $rowNumber ) )]

Daniel Smith

unread,
May 19, 2015, 6:29:05 PM5/19/15
to modular-...@googlegroups.com
Is there a way to "Evaluate" each row to set the Fields in the database?

No, there isn't. As Jeremy mentioned, you can assign the values to local variables, but you can't set multiple fields in a single calculation.
(actually, you could use an auto enter calculation that is defined to return the value of a local variable, but I wouldn't suggest this method over explicitly setting the fields's value)

 If not, I supposed I'll have to loop through each row and do a 'Set Field by Name" on each variable.

If you're working with a known set of names, why not use a 'Set Field' step? You could potentially abstract it by using 'Set Field by Name', but then you'd also have to get the list of named values via the #GetNameList function (I think that's the name; I'm doing this from memory).

FYI: In addition to the JSON module, there is now a set of native JSON custom function and plugin backed custom functions available. If you're already familiar with the #Parameters and JSON modules, you'll probably want to just keep using them, but just so you know, there are other options available now.

--
You received this message because you are subscribed to the Google Groups "Modular FileMaker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modular-filema...@googlegroups.com.
To post to this group, send email to modular-...@googlegroups.com.
Visit this group at http://groups.google.com/group/modular-filemaker.
To view this discussion on the web visit https://groups.google.com/d/msgid/modular-filemaker/394f7e92-7581-44e6-a4a1-48135ff56c14%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Gary Wong

unread,
May 19, 2015, 6:39:28 PM5/19/15
to modular-...@googlegroups.com
Daniel hit 'Post' just before I posted my 2nd reply.. and since his answered my question, I deleted my 2nd reply.  Thanks to you both and have a great week.

gary
Reply all
Reply to author
Forward
0 new messages