I have been using Xojo for about a year and making great progress. One of the areas that I have been branching into is JSON. I have a fairly complex app that uses it extensively. In the first iteration it’s messy code and clearly beginner work. The app works fine but the code needs clean up and optimization. The app is using Xojo.Core.Dictionary statements.
In building a scaled down version to make the code tighter I used JSONItem statements. However, it looks like I should stick with Xojo.Core.Dictionary. Can I get some guidance?
- Is there a difference?
- Is on preferable over the other?
- I develop on a MAC and deploy to both Windows and MAC. Will also deploy to Linux / Raspberry and iOS in the future.
- I read older notes that JSONItem is not available on iOS has that changed? Will it?
Just trying to make sure I don’t end up somewhere needing to recode everything because I made the wrong choice.
Thanks for the help.
There are a few considerations here.
For now, iOS requires Xojo.Core.Dictionary but that’s going to change with API 2.0. Nobody knows the exact timetable on that though so if your code needs to run on iOS now, use Xojo.Core.Dictionary.
If it doesn’t, know that Xojo.Core.Dictionary is slower than Dictionary and (presumably) JSONItem, and can be much slower on Windows/Linux. For that reason, I wouldn’t use Xojo.Core.Dictionary for anything that has to be deployed cross-platform.
But JSONItem has its own issues, notably it is slow to render with large JSON. If you are going to go that route anyway, consider using my drop-in replacement, JSONItem_MTC. It works the same way but is significantly faster while avoiding some bugs that still exist in JSONItem.
Better yet, in the develop branch I linked above, there are ParseJSON and GenerateJSON functions that work just like Xojo.Data.ParseJSON and Xojo.Data.GenerateJSON for the classic framework (soon to be API 2.0). While none of these yet work on iOS, they will eventually and you should determine your own timeline when deciding.
Hope that helps.
thank you that is most helpful. I plan on trying JSONItem_MTC in the project I am building now.