I ended up writing a wrapper method called SelectionToJSON (named to match
our existing naming convention), which is called like this:

SelectionToJSON("Table";"[Table]Field1;[Table]Field2;[RelatedTable]Field1")

Inside the method, it breaks apart the second parameter and builds a
template object. If the field is not part of the main method, it prepends
"TableName_" to the JSON key.

It does rely on having the automatic relations set up in the structure,
which I had to play around with to get working. I ended up having to call
Set Automation Relations(True;True) at the beginning of the method.

As to whether Selection to JSON should be used in production, it seems to me
like it's meant to be used because it's a LOT faster than looping through
arrays and building JSON strings manually, which is what we used to do. I've
cut 30 second response times down to 10, for very large lists.



--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to