Class {@code com.acme.Person} must either implement {@link Convertible},
* or be mapped with a {@link Convertor} via {@link Factory#putConvertor(String, Convertor)}.
+ *
JSON arrays are by default represented with a {@code List
*/
public class AsyncJSON
{
@@ -75,8 +79,31 @@ public class AsyncJSON
{
private Index.Mutable cache;
private Map convertors;
+ private Function, Object> arrayConverter = list -> list;
private boolean detailedParseException;
+ /**
+ * @return the function to customize the Java representation of JSON arrays
+ * @see #setArrayConverter(Function)
+ */
+ public Function, Object> getArrayConverter()
+ {
+ return arrayConverter;
+ }
+
+ /**
+ *
Sets the function to convert JSON arrays from their default Java
+ * representation, a {@code List
+ *
+ * @param arrayConverter the function to customize the Java representation of JSON arrays
+ * @see #getArrayConverter()
+ */
+ public void setArrayConverter(Function, Object> arrayConverter)
+ {
+ this.arrayConverter = Objects.requireNonNull(arrayConverter);
+ }
+
/**
* @return whether a parse failure should report the whole JSON string or just the last chunk
*/
@@ -870,9 +897,10 @@ public class AsyncJSON
case ']':
{
buffer.get();
- Object array = stack.peek().value;
+ @SuppressWarnings("unchecked")
+ List