Comments on new JSON handling

Kem - the link does not open. Can you fix that, or is that a forum issue, interpreting URLs incorrectly?

I edited Kem’s post to fix the Feedback link.

This question is sort of in the same vein since we are talking about the new son. Does anyone know how well it performs , speed wise for parsing into new objects? i.e. faster than jsonitem. And maybe compared to MBS version?
If no I might do some tests

[quote=180975:@James Nicholson-Plank]This question is sort of in the same vein since we are talking about the new son. Does anyone know how well it performs , speed wise for parsing into new objects? i.e. faster than jsonitem. And maybe compared to MBS version?
[/quote]

It’ll almost certainly be faster than the JSONItem classes and use less memory.

I have testing set up in my JSONItem_MTC project. I’ll add this and report back.

I haven’t speed tested yet but did find a difference in the handling of doubles. Try adding 1.2 to old and new to see what I mean.

And it’s a little odd that this works. A bug?

  dim j as string = Xojo.Data.GenerateJSON( 1 )
  // j = "1"

Actually perfectly allowable in the JSON spec to have only one value without a container. Generally not very useful, but allowable.

Conclusion: The new framework’s handling of JSON using the Xojo.Core.Dictionary and array of Auto is significantly faster than either the native JSONItem or my replacement class, JSONItem_MTC:

JSONItem Create: 7,840
JSONItem_MTC Create: 5,338
Xojo.Core.Dictionary Create: 2,882
JSONItem.ToString: 169,305
JSONItem_MTC.ToString: 20,429
Xojo.Data.GenerateJSON: 2,585
... but they don't match
JSONItem.Load: 95,295
JSONItem_MTC.Load: 12,302
Xojo.Data.ParseJSON: 4,225
JSONItem.Create (big): 35,628
JSONItem_MTC.Create (big): 36,746
Xojo.Core.Dictionay (big): 33,804
JSONItem.ToString (big): 3,256,181
JSONItem_MTC.ToString (big): 160,820
Xojo.Data.GenerateJSON (big): 18,633
JSONItem.Load (big): 539,996
JSONItem_MTC.Load (big): 109,787
Xojo.Data.ParseJSON (big): 57,195

“They don’t match” because the native keeps the order of the elements added to a Dictionary, but the new handling does not. This should not make a difference.

Nice work testing this Kem! Thank you.

You should compare the number of memory allocations made ;).

Great Kem
Thanks for the effort. The new json looks great for speed

James

Yes. Unfortunately, now I have to re-write part of my XDC presentation and demo projects around it. grumble

having to rewrite your presentation at the last minute before giving it because you learned something new about the topic, is a badge of honor. Many of us have that badge… I know I do.

Well, it’s been updated. Now I hope I have time for it all. :slight_smile:

If anyone got the Serialization class I mentioned, I’ve updated it to use the new framework so it will be faster. However, I’m not going to give it out until after XDC since I’ll probably be making more changes to it.

Does anyone have an idea of how the updated JSON stuff compares to MBS JSON methods?

With the previous version the MBS stuff processed JSON in literally 1000th the time.

Well, yes and no. MBS front-loads the processing as I recall so rendering to string was faster, but loading (IIRC) was slower.

I have a branch of the project that includes MBS so I can run that later and let you know.

My tests were round-trip.

I had a fairly complicated JSON file/string that I parsed out to the library’s memory structure (different, unfortunately) and then encoded back into JSON.

I’m curious to hear what you find, thanks.

Here are the results from the older branch that have the MBS tests. You can compare to the numbers above. Pay no attention to the "but does not match " messages.

JSONItem Create: 5,887
JSONItem_MTC Create: 5,241
JSONMBS Create: 10,657
JSONItem.ToString: 164,440
JSONItem_MTC.ToString: 12,232
JSONMBS.ToString: 2,573
JSONItem.Load: 90,580
JSONItem_MTC.Load: 11,797
JSONMBS.Load: 2,167
JSONItem.Create (big): 34,139
JSONItem_MTC.Create (big): 34,612
JSONMBS.Create (big): 210,476
JSONItem.ToString (big): 3,196,286
JSONItem_MTC.ToString (big): 158,320
... but they don't match
JSONMBS.ToString (big): 3,598
... but it doesn't match JSONItem
... but it doesn't match JSONItem_MTC
JSONItem.Load (big): 536,337
JSONItem_MTC.Load (big): 112,236
JSONMBS.Load (big): 3,622