Maintain Order in JSON Import
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Sep 14 22:01:27 EDT 2016
The use case is cross session data on mobile where we would like to be able to examine/change the "array" in a text editor.
if the user shuts down the app, you must save the data somewhere, and reload to gUserSettings on start up. So, yes, agreed, there are many ways to accomplish this. The only way to save an encoded array would be to insert is a a custom property in an LC stack and save to the writeable folder on mobile.
disclaimer: this is all a bit new to me so "best architecture" for me is "most transparent" architecture. And since we have done and will continue to do a lot of API calls to and from the web server, where a lean text only data format (JSON) is useful.. I'm look at using JSON for this kind of thing… so this "kinda" goes along with the whole externalization of code to text documents (scripts, stacks, libs, behaviors) that are all readable in a text editor… having JSON also as the container means we have this model working there too. So I can change a value in a user setting (in a text editor) and then in the app see that my calls are actually working.
I've got it working now… no issues really, other than my own learning curve and being sure not to break any json by hand.
Actually if I just let the jsonExport and jsonImport do the work… it's valid json… except that what's on disk is all on a single line.
On 9/14/16, 11:28 AM, "use-livecode on behalf of Richard Gaskin" <use-livecode-bounces at lists.runrev.com on behalf of ambassador at fourthworld.com> wrote:
Do you need to round-trip? Where does the data come from, and where is
it going?
If any part of that is LC on both ends you can save _much_ time for that
using an encoded array.
More information about the use-livecode
mailing list