JSONItem encoding issue in 2021 releases

No Blog Post (written by me) intended… but here is a quick and dirty example project: JSONItemValueFix.xojo_binary_project

1 Like

I’m sure when @Jürg_Otter said he subclasses everything, he meant that he does it for a reason, to get specialized functionality that isn’t provided out of the box. I also assume that he makes his subclasses external, so any updates or fixes are immediately available in all of his projects.

I do the same and I have made statements like “The first thing I did with Xojo is subclass all the controls.” That certainly shouldn’t imply that I created empty subclasses. That would be absurd. It means that I evaluated the functionality provided out of the box and adjusted it to my needs. I would encourage others to do the same, which I believe @Jürg_Otter was doing.

2 Likes

One thing I just found that is strange to me is that WebRequest.Path shows that it has no encoding, i.e. it is nil in the debugger. When I attempt to add the value from this to a JSONItem, the JSONItem seems to become invalid and will no longer produce the expected ToString value. It seems I’m going to need to do a decent amount of wrapping throughout my app to ensure that a String has the expected encoding. Honestly, it seems it would be better to throw the exception when the .Value is being added to the JSONItem rather than when the ToString is being called, which would significantly help find the location where the error is actually happening.

See related issues such as Session.URLParameter nil encoding

It’s not clear to me what the optimal solution is: the framework should not deliver strings with nil or wrong encodings, but also the JSON framework could possibly be more tolerant? e.g. if all Nil encoding strings were assumed to be UTF8, would this perhaps solve 99% of the issues?

1 Like

I am building a solution with a web app between iOS and mysql DB’s and so far it has been a nightmare, mostly because of sad Xojo documentation and examples, but also because JSON was giving me too much trouble. As a solution I replaced JSON with my own code, which btw produces not even half the https code of JSON and works perfect. Glad they fixed stuff in the latest release of Xojo, but unfortunately my licence is out…

@Christian_Schmitz, tuve que usar esa función para solucionar el problema con JSON y MySQL, creo que Xojo no debería presentar ese problema y no tendríamos que estar recurriendo a eso, pero quedó solucionado, muchas gracias!

1 Like