JSONItem replacement

  1. 5 years ago

    Kem T

    13 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    I'm just about finished with a drop-in replacement for JSONItem. It's all Xojo code and emulates all features and functionality of the native class, except:

    • It's around as fast, if not faster, to create and load.
    • It handles Unicode characters correctly for both values and, in objects, names.
    • It throws an exception if you try to add a value it can't handle rather than waiting until you call ToString.
    • It is something like 40 times faster when generating large JSON strings. (That is not a typo.)

    The last point is why I undertook the project at all. In my test case of 10,000 objects, it takes the native class 4.7 seconds to render a string. It takes my class around 106 milliseconds.

    To use it, you'd find and replace all occurrences of JSONItem with JSONItem_MTC, then drag the class to your project.

    If there is interest, I will post this as an open-source project on my web site when I get back from vacation. Is there interest?

  2. Oliver O

    13 Aug 2014 Pre-Release Testers, Xojo Pro https://udemy.seminar.pro

    Very generous offer! Yes, making it open source (on github?) would be highly appreciated.

  3. Matthew C

    13 Aug 2014 Pre-Release Testers Roanoke, VA - Spartanburg, VA

    Github!

  4. Christian S

    13 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Is it faster than my JSON plugin class?

  5. Christian S

    13 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Another thing: Please talk to Xojo engineers about it. Because if it's so fast, why not give it to Xojo Inc. and let it become the new implementation of JSONItem class?
    That would speed up all the web stuff instantly.

  6. Torsten G

    13 Aug 2014 Europe.Germany.MacBookPro
    Edited 5 years ago

    @ChristianSchmitz
    Another thing: Please talk to Xojo engineers about it. Because if it's so fast, why not give it to Xojo Inc. and let it become the new implementation of JSONItem class?
    That would speed up all the web stuff instantly.

    +1
    And Kem's name should be mentioned in the docs for this contribution.

    An additional version on github or Kem's website would be great also. So we can individually adapte his code if necessary.

    Many thanks to Kem if this comes true.

  7. Christian S

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    By the way, Kem do you handle duplicate key names well?

  8. Ian J

    14 Aug 2014 Pre-Release Testers, Xojo Pro Somerset, UK

    This would be awesome Kem!

    I like the idea of perhaps Xojo being able to build it in if compatible, as long as it has a BSD, MIT or other permissive license there's a chance they'll look at it.

  9. Peter F

    14 Aug 2014 Pre-Release Testers, Xojo Pro New England

    @Kem T - That would be great. I could embrace JSON again instead of cringing :)

  10. Kem T

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    @ChristianSchmitz Is it faster than my JSON plugin class?

    I didn't test that. I'd suspect not, but I could certainly give it a try.

  11. Kem T

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    @ChristianSchmitz Another thing: Please talk to Xojo engineers about it. Because if it's so fast, why not give it to Xojo Inc. and let it become the new implementation of JSONItem class?
    That would speed up all the web stuff instantly.

    I plan to release it as open source and free to use by anyone for any purpose, including by Xojo. (That would be neat though. :) )

  12. Kem T

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    @ChristianSchmitz By the way, Kem do you handle duplicate key names well?

    Yes, I used the same technique as in my case-sensitive Dictionary, i.e., names are converted to UTF-8, then hex-encoded.

  13. Antonio R

    14 Aug 2014 Pre-Release Testers, Xojo Pro Europe (Italy)

    I'm interested in speed json string generation.
    Actually I've an extension to JSONitem that is far faster than the Xojo one.

  14. Oliver S

    14 Aug 2014 North Yorkshire, United Kingdo...

    This is cool. I did not even know there was a class built-in to Xojo for this. I have worked with JSON text generating and I did not use a class. Good to know about your project Kem, thanks.

  15. Mike C

    14 Aug 2014 Pre-Release Testers, Xojo Pro North Carolina (USA)

    Excellent work Kem and thank you for your commitment to the Xojo community!

  16. Kem T

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    Is there an existing Interface like "StringProvider" or the like? For example, suppose I have an object that can be converted to a string, and I want the world to know. Is there some interface for that purpose?

    If not, would it be useful to add that and have my class recognize it? It would mean adding two items to your project instead of the one.

  17. Rick A

    14 Aug 2014 (Brazil. GMT-3:00)

    It's usual the objects that can be converted to string have a .ToString() method.

  18. Rick A

    14 Aug 2014 (Brazil. GMT-3:00)
    Edited 5 years ago

    What's the best approach to find the existence of a method in a object and invoke it in Xojo?
    The ToString() probably could be part of some kind of Serializable Interface.

  19. Kem T

    14 Aug 2014 Pre-Release Testers, Xojo Pro, XDC Speakers Connecticut

    And then I heard the voices in my head say, "but if it can be converted to a string, why wouldn't it just be added as a string?"

    I agree that a serializable interface would be useful, but I won't do that as part of this project.

  20. Rick A

    14 Aug 2014 (Brazil. GMT-3:00)

    @Kem T "but if it can be converted to a string, why wouldn't it just be added as a string?"

    Not following. You mean:

    Dim o As New MyObject
    Dim s As String = o // ???

    In contrast to:

    Dim o As New MyObject
    Dim s As String = o.ToString()

  21. Newer ›

or Sign Up to reply!