I'm trying to consume a variety of JSON-emitting web services in a more
structured/typesafe way than just getting back json and doing JSON.get to
extract relevant parts. So I've declared classes that describe the
structure of the expected values, and doing
query.setSerializer(new JSONSerializer(foo.class));
where foo is the class corresponding to the top level of the json.
I've already done this exercise in C#, where you pretty much have to declare
such classes, so I'm pretty confident I have the right structures. But I've
only gotten this to work in Pivot on the most trivial example (a web call
that returns an object with two name/value pairs, and I declare the object
accordingly). On more complicated cases, I get errors. Here are two of
them:
java.lang.IllegalArgumentException: Cannot convert array to class
[Lcom.fxpal.myunity.UCamera;.
org.apache.pivot.serialization.SerializationException: Cannot convert
number to null.
Yes, that first error literally has those nonsensical bracket, L, and
semicolon (there is a class, com.fxpal.myunity.UCamera, within the structure
of that one).
How on earth do I debug this? Both web calls return perfectly ordinary
JSON, which Pivot is happy to parse as generic json if I don't specify a
serializer.
Bonus question: some of the services I want to consume return a JSON array
of some object type. How do I create a JSONSerializer for that?