2012-09-18, 19:24
(2012-09-18, 17:57)Tolriq Wrote: There's case like direct Class mapping in high level Json usage or direct streaming parsing in low level where checking if string or array or null depending on case is not really possible or needs very ugly hacks with bad perfomances.
I know. I am using gson since I was already familiar with this library and liked its direct json to class mapping.
Gson has a streaming mode which is nice for large data sets since it reads junk by junk. There is a function peek() which allows you to test the type of an object before processing it. This works actually really well but is a low level api which requires to write a lot of (boring) code.
I was trying to use direct class mapping for all requests which are not performance critical and used two different classes, one for api v4 and one for api v5 (after the big json change in august). But since Files.GetDirectory can return a string or an array in api level v5 this wasn't working properly. I think that it is possible to write a small deserializer to handle the array/string case properly. I just have to look into it.