diff options
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java | 6 | ||||
-rw-r--r-- | gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java index 996f245c..113d6fd6 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/builders/JsonBuilderBase.java @@ -26,6 +26,7 @@ import com.google.gwt.query.client.js.JsObjectArray; import com.google.gwt.query.client.js.JsUtils; import java.util.Arrays; +import java.util.Collection; import java.util.List; /** @@ -166,6 +167,11 @@ public abstract class JsonBuilderBase<J extends JsonBuilderBase<?>> implements J public <T extends IsProperties> T set(Object key, Object val) { if (val instanceof IsProperties) { p.set(key, ((IsProperties) val).getDataImpl()); + } else if (val instanceof Object[]) { + setArrayBase(String.valueOf(key), (Object[]) val); + } else if (val instanceof Collection) { + Collection collection = (Collection) val; + setArrayBase(String.valueOf(key), collection.toArray(new Object[collection.size()])); } else { p.set(key, val); } diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java index 3652ab43..903ef138 100644 --- a/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java +++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/dbinding/DataBindingTestJre.java @@ -230,11 +230,11 @@ public class DataBindingTestJre extends GWTTestCase { user.set("name", "Random Name"); user.set("phones", Collections.emptyList()); String json = user.toJson(); - + //WHEN fetching that user GUser retrievedUser = GQ.create(GUser.class); retrievedUser.parse(json, true); - + //THEN assertEquals(0, retrievedUser.getPhones().size()); } |