2021 R1 no longer updates JSONItem values

Hi Xojo Team,

First… thank you for the new 2021 release… looking forward to dig into it.

I just have a question… it seems that updating JSONItems no longer updates similar to how its does in 2020. Here is some code to illustrate what I mean…

Dim a As new JSONItem("{"“obj”":{"“a”":1}}")
Dim b As JSONItem = a.Child(“obj”)
b.Value(“a”) = 2
MsgBox Str(a.Child(“obj”).Value(“a”))

In Xojo 2020 the MsgBox outputs 2, but in Xojo 2021, it outputs 1.

Is this by design, or a bug?

If this is by design, would there be any workarounds so that I can assign part of the JSON to a separate variable by reference, and make assignments that still also updates the original variable?

One of our projects relies heavily on the ability to do this.

Thank you in advance.

Alwyn

I can confirm the behavior in 2021 R1 (though I can’t say for sure how it used to work).

If this is a change, it’s a subtle one and is could break a lot of code.

In fact, I think the problem is even more basic. It can be reproduced without using the other “b” variable, as follows:

Dim a As new JSONItem("{""obj"":{""a"":1}}")
a.child("obj").value("a") = 3
MsgBox Str(a.Child("obj").Value("a"))

In Xojo 2020R1 the result is “3”
In Xojo 2021R1 the result is “1”

Also, the Language Reference (LR) is weird - although there are examples of using JSONItem.value, the actual “value” method is missing from the LR.

Something’s not right.

Submitted two feedback cases:

1 Like

Thanks Mike. I’ve added my support for ticket 64245, since I can’t move on with the next Xojo version until this is fixed.

It is interesting to note that this bug is related to the object only, it is not present if you have an object vector.
In that case the modification is successful
IE:
{“obj”:{“a”:“test”}, “vo”:[{“a”:"test1}, {“a”:“test2”}]}
var j as new jsonItem()
j.child(“obj”).value(“a”)=“newTest”
=>to string is the same
j.child(“vo”).childAt(0).value(“a”)=“newTest1”
=>to string shows the updated jsonString

Perhaps a clue about where the bug might be hiding.

Fixed for the next release. That I hope that is a dot release.
I can’t stand with data corruption bugs, specially those occurring silently.

3 Likes