uInt64 and xojo.core.dictionary

Hi all!

My application communicates with external APIs via JSON.

In my application, this JSON is translated into xojo.core.dictionary.

The problem is that the external API (which I don’t control) sends uint64 (unsigned bigInt from Mysql) and the xojo.core.dictionary apparently accepts int64 at most. If the number sent by the API exceeds the maximum number of int64 (9223372036854775807), the number sent will be replaced by 9223372036854775807 in the dictionary. I tried to cast it, etc., but I couldn’t find a solution.

Do you know how to solve this problem in a relatively simple way without having to manually process JSON?

Please try JSONMBS class instead. It can handle longer numbers without problems as

NewNumberNode(value as string) as JSONMBS

can take any text string for a number.

Thank you Christian. As usual, I’d better use your plugins from the beginning…

The problem is that I have a lot of dictionaries to change if I have to replace them with MBS. I will evaluate the time needed to do it. I also need to look at the MBS methods to convert the dictionary to JSON and vice versa.

I’m disappointed that Xojo’s dictionary doesn’t support uInt64. With the generalization of APIs, and since most database ids are uInt64, it’s a problem.

Obviously, the alternative solution is to assume
that the IDs I will receive will never exceed the capacity of an int64, they are auto-incrementing IDs from the Mysql tables. I know the data from my client’s external database, I don’t see how the Id’s could reach the number of 9 223 372 036 854 775 807. But of course, one should never make assumptions and not process the data in the right format!

Check the Convert method on JSONMBS to convert between dictionary/array and our JSONMBS objects.

1 Like