As this is a general question about JSONItem.ToString()-performance, I have no source code as an example.
I have a database request which results in an about 848KB size for a string after JSONItem.ToString().
The table was 10 columns and 4200 rows; the JSONItem object is already built up.
I am only talking about performance of the ToString()-method.
I already measured encodeBase64 and database request itself and converting to JSONItem -> they are all very fast!
The call to ToString() needed about 4 seconds.
First, is this speed to be assumed for the given result bytes amount?
My guess is the following: the performance is not so good because no string builder is used internally but string is repeatedly extended on and on.
Hopefully I am wrong here.
So, last question, is there an add-on/class from Monkeybread Software for faster JSONItem-to-string handling?
Unfortunately, did not find it.
What have ParseJSON and GenerateJSON to do with JSONItem toString()???
As, I wrote ToString() for JSONItem is slow.
And AddItemToArray() or JSONMBS.newStringNode("") seems to be slow.
The benchmark example which is given for MonkeyBread Software’s JSONMBS also shows that JSON creation is slower for JSONMBS compared to Xojo’s JSONItem; which was horrible for me to see:-(
As I serialize the data catched from the database via web socket, I could build up the JSON string as what it is a string.
But as the string gets big (848KB), I would bet to have the same problem.
So, next task for me is to see if StringBuilder is avaiable for Xojo.
What have ParseJSON and GenerateJSON to do with JSONItem toString()???
As, I wrote ToString() for JSONItem is slow.
And AddItemToArray() or JSONMBS.newStringNode("") seems to be slow.
The benchmark example which is given for MonkeyBread Software’s JSONMBS also shows that JSON creation is slower for JSONMBS compared to Xojo’s JSONItem; which was horrible for me to see:-(
As I serialize the data catched from the database via web socket, I could build up the JSON string as what it is a string.
But as the string gets big (848KB), I would bet to have the same problem.
So, next task for me is to see if StringBuilder is avaiable for Xojo.
Still ned help with this;-)
Thanks![/quote]
You can use those functions to parseJSON or GenerateJSON from or to a dictionary instead of using JSONItem.
JSONItem is known for being “slow” @Kem Tekinay has some classes Einhugur has json plugins and MBS has JSON plugins
and ChilkatSoft all are Alternatives to JSONItem usage.
If .ToString is too slow, don’t expect it to get faster by “saying JSONItem.ToString is slow”. So you might wanna use one of the alternatives instead to workaround your issue.