|
Now we've got a format that's starting to gain traction, a JSONification of stream of news displayed by River2. A bunch of Javascript devs are working on renderings of this data, some of which are now already nicer than the one I use, but none are yet functional enough for me to switch to. But there's a problem with the JSON.
XML deals with it differently, they just allow more than one item with the same name. This causes other, different, headaches. http://scripting.com/images/2010/12/17/jsonShot.gif In the screen shot above, there are two "updatedFeed" elements. The first has only one item, the second has more than one. This causes problems for people in some languages because (apparently) it's hard for them to deal with an object without, in advance, knowing its type. So they say the solution is simple, always make it a list. Simple for them, but... But this is not so simple on my end. Because I'm using a generic JSON serializer, and it would have no way of knowing that "item" should always be a list. Unless... One way of dealing with this (that I don't like and won't do) is to make everything a list. I was just wondering what other JSON-producing environments do in situations like this. PS: I have a workaround I can do fairly quickly that side-steps the problem, so it won't ultimately be a deal-stopper. But I'd like to solve the problem entirely in the serializer if possible, so the solution can be work in other cases. |