With the Xojo framework being deemphasized in favor of API 2.0, what’s currently the best way to handle parsing JSON for the iOS target and in general?
It seems JSONItem still doesn’t work, but I don’t want to put a lot of effort towards using Xojo.Data’s GenerateJSON and ParseJSON methods as I’m guessing they’ll soon be deprecate much like Xojo.Core.Dictionary was…
Is the recommended practice to handle everything using the Dictionary class and the new GenerateJSON and ParseJSON methods in API 2.0?
@Christian_Schmitz - does the JSONMBS class in the “The MBS Xojo Util Plugin” work for iOS builds?
JSONItem performance is unaffected right now, so my class is still relevant. I suspect this won’t be the case forever though, but still, if I were starting with JSON today, I’d dispense with JSONItem and use ParseJSON and GenerateJSON directly in all cases.
I realize I didn’t answer your performance question. Yes, the API methods are significantly faster than JSONItem or my JSONItem_MTC class, which is another reason I’d choose them.
Speedwise, I expect GenerateJSON and ParseJSON be faster than anything a plugin could do, as the framework internally can access arrays and dictionaries faster.
@Kem_Tekinay It’s less about any result being particularly massive and more about potentially having to process “chunky-ish” (1000-15000 values which may have arrays in each of them) results multiple times in relatively quick succession. Parsing multiple, sets of results returned from an API.
@Christian_Schmitz Is your plugin able to utilize multiple cores? As explained above, I’m not parsing one result with a million rows. I’m needing to parse “tens of sets of data” returned in quick succession. (out of order processing is OK)
Thanks to both of you for your thoughtful questions and advice!
I’m currently updating an app I wrote last year to API2.0. I was already using ParseJSON from the old API. I found out that the new version uses Variant instead of Auto so it required some code modification to access the data without “Suddenly…BLAM!” happening.
You can try JavaScriptEngineMBS class to have a JavaScript engine within Xojo.
And it can of course work with JSON. And you can run functions multithreaded.