In checking a few of my apps I found one that uses your Kaju (which I appreciate very much.) It has 18 places where “JSONitem” is used, 17 are within the Kaju class.
Should I change all 18 to use "JSONitem_MTC?
Thanks again you and Luke and Jeremy Cowger for KAJU.
I just released JSONItem_MTC v.4.0. While there have been no functional changes to that class, the project now includes M_JSON, and that includes ParseJSON_MTC and GenerateJSON_MTC. As you might guess, those do what the new framework Xojo.Data. functions do, but with the classic (soon to be API 2.0) framework. In other words, rather than working with Text, Xojo.Core.Dictionary, and Auto(), they work with String, Dictionary, and Variant().
GenerateJSON_MTC also has an optional parameter to produce “pretty” output.
The JSONItem_MTC project has been update to 4.1. This is a minor change that only affects debugging. When the keys of JSON objects are stored internally, they used to be converted to/from hex to preserve case-sensitivity. Now they are stored in the form key-HEX.
I’ve updated the project to 4.1.1. It turns out that M_JSON was not encoding embedded quotes or backslashes, a mistake so embarrassing that I wish @Thom McGrath had caused it instead of merely reporting it. Alas, I am left with nobody else to blame, and hope it didn’t cause any headaches.
[quote=263359:@Kem Tekinay]JSONItem_MTC , the drop in replacement for the classic framework JSONItem
If you’re using JSONItem, I encourage you to consider this instead.[/quote]
I’ve been using JSONItem_MTC in a project, and noticed the speed improvement. So thanks a lot!
In another project it seems I have run into a limitation, which doesn’t make JSONItem_MTC a “drop in replacement”
It seems that JSONItem_MTC can’t handle Array-Values
Here is an example project showing the issue/difference.
This works as expected with JSONItem:
Dim oJSON As New JSONItem
oJSON.Value("field") = "a_fieldname"
oJSON.Value("operator") = "IN"
oJSON.Value("values") = Array(12, 15, 20)
JSONItem_MTC however raises a JSONException( "Illegal Value", 10 ).
One could modify it’s .Validate to cope with Arrays (get the DataType of the Array-element-type -> TypeArray is logically OR’ed with the element type):
Dim iCheckVariantType As Integer = Bitwise.BitAnd(value.type, Bitwise.OnesComplement(Variant.TypeArray))
select case iCheckVariantType
But then .Serialize -> .EncodeValue will fail.
That’s why I’ve stopped trying the do further modifications… at least before asking if you intend JSONItem_MTC to handle Array-values sooner or later?
Please pull the latest develop branch of the project. It includes unit tests to show what works for JSONItem_MTC now, and what does and doesn’t work with JSONItem.
Norman’s deleted post contained code that doesn’t work on the current release version, but does work on the develop branch that contains that fix. I’ll release it as soon as I am comfortable that it now works correctly and matches (or, in this case, exceeds) the native version.
I’ll do that in the next couple of days.
I haven’t even thought about looking into the other branches beforehand… but it seems that you’ve checked in a fix after my last post and not have done that work long ago with me not finding it (by not looking into the dev-branch).
Yeah - sorry about that
It might have been worth being picky, if that has helped to improve JSONItem_MTC even more.
Anyway - thanks a lot for the fix! I’ll see how it works for this project when I get back to it.
Yeah, unfortunately Norman deleted his post so the responses are now out of context. That was in response to code he posted that he claimed still didn’t work, but I’m pretty sure he tried it against the release (master branch) instead of the just-fixed develop branch.
Anyway, let me know what you find. Since this class has been out literally for years without anyone noticing, I guess I can wait another few days to make sure the fix is right.
Picky again…?
There’s a typo here: raise new JSONException( "This JSONItem_MTC is an obect", 13 )
And another one in the release notes of the Dev-Branch: JSONItem_MTC will roperly deal with assignments of arrays.