Is there a quick/easy way to tell what it's a JSONItem that it can't convert to string?

I have a complex data structure stored in a dictionary, I did this so it would be easy to export as a JSON string… Only thing is, it doesn’t. It generates an exception, with no indication as to what it doesn’t like.

Apart from stripping it down and working my way slowly through, are there any tricks to figuring this out quickly?

Classic or Xojo framework?

I wouldn’t expect the JSON classes to work with Structures inside.
Only arrays, text, string, numbers and booleans.

[quote=289273:@Christian Schmitz]I wouldn’t expect the JSON classes to work with Structures inside.
Only arrays, text, string, numbers and booleans.[/quote]
To be specific, Arrays of other JSON objects… oh and Nulls are allowed too.

Fwiw, I’m not sure that the new framework supports String, nor do I think that the old framework supports Text.

So as Wayne said, it would be helpful to know which framework you’re using and also which IDE, just in case there’s been a bug fix since then.

Since obviously you know what is in the dictionary, have you tried to look for it in the generated json ?

Classic framework.[quote=289273:@Christian Schmitz]I wouldn’t expect the JSON classes to work with Structures inside.
Only arrays, text, string, numbers and booleans.[/quote]
While building the data, I have tried to ensure that it only stores these types, I’m suspecting that I may have slipped up somewhere. It’s just figuring out where.

Ah… What about arrays of other objects or only JSONItem arrays?

It fails when I try to generate the JSON string.

Check the message on the JSONException. That may give us a starting point.

Yeah, that’s probably your problem. If you’ve got an array assigned to an element of your dictionary, it will just be stuffed in as the value.

There is another way you could handle this though. Instead of using a dictionary, why not just use a JSONItem for your data structure. It’s backed by a dictionary under the hood anyway.

I might just do that, I’ll have a think because it also means I need to update my code to convert to NSDictionaries for this too.

My main data file is a property list, so it does conversion to and from when writing. I was just adding copy & paste and was going to use JSON string for copying the data to the clipboard, in the end I used NSArchiver.

Ideally I want to get away from NSDictionaries and property lists as this keeps me locked into Apple’s platforms only. I did notice that JSON was a little slow writing my entire data structure to disk. So I might dig up some old code for writing dictionaries as binary files.

We have some code that will use introspection that will convert between JSON and class objects. But it might not be what you’re looking for.