I would like to write a custom serializer for a JSON field that accepts mixed typed data as value (coercion). Here are two JSON samples {"foo": ["foo", "bar", "baz"]} and { "foo": "bar" }. Parsing such a JSON with a standard bean will obviously fail since a String won't be cast into an Array and vice versa.
class MyBean {
private String foo; // Wil fail when an array is provided
}
class MyBean {
private String[] foo; // Wil fail when a string is provided
}
Hi there,
I would like to write a custom serializer for a JSON field that accepts mixed typed data as value (coercion). Here are two JSON samples
{"foo": ["foo", "bar", "baz"]}
and{ "foo": "bar" }
. Parsing such a JSON with a standard bean will obviously fail since a String won't be cast into an Array and vice versa.How can this be achieved with Boon ?
I'll appreciate any help ! Thanks :)