Skip to content

Commit 93b859a

Browse files
committed
Small fixes.
1 parent cb0f340 commit 93b859a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.esotericsoftware</groupId>
77
<artifactId>jsonbeans</artifactId>
8-
<version>0.8-SNAPSHOT</version>
8+
<version>1.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010
<name>JsonBeans</name>
1111
<description>Java object graphs, to and from JSON automatically</description>

src/com/esotericsoftware/jsonbeans/Json.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public void readFields (Object object, JsonValue jsonMap) {
763763
Class type = object.getClass();
764764
ObjectMap<String, FieldMetadata> fields = getFields(type);
765765
for (JsonValue child = jsonMap.child; child != null; child = child.next) {
766-
FieldMetadata metadata = fields.get(child.name());
766+
FieldMetadata metadata = fields.get(child.name().replace(" ", "_"));
767767
if (metadata == null) {
768768
if (ignoreUnknownFields) {
769769
if (debug) System.out.println("Ignoring unknown field: " + child.name() + " (" + type.getName() + ")");
@@ -864,6 +864,8 @@ public <T> T readValue (Class<T> type, Class elementType, JsonValue jsonData) {
864864
if (typeName != null && Collection.class.isAssignableFrom(type)) {
865865
// JSON object wrapper to specify type.
866866
jsonData = jsonData.get("items");
867+
if (jsonData == null)
868+
throw new JsonException("Unable to convert object to collection: " + jsonData + " (" + type.getName() + ")");
867869
} else {
868870
JsonSerializer serializer = classToSerializer.get(type);
869871
if (serializer != null) return (T)serializer.read(this, jsonData, type);

src/com/esotericsoftware/jsonbeans/JsonValue.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* for (JsonValue entry = map.child; entry != null; entry = entry.next)
1616
* System.out.println(entry.name + " = " + entry.asString());
1717
* </pre>
18+
*
1819
* @author Nathan Sweet */
1920
public class JsonValue implements Iterable<JsonValue> {
2021
private ValueType type;
@@ -65,7 +66,7 @@ public JsonValue get (int index) {
6566
* @return May be null. */
6667
public JsonValue get (String name) {
6768
JsonValue current = child;
68-
while (current != null && !current.name.equalsIgnoreCase(name))
69+
while (current != null && (current.name == null || !current.name.equalsIgnoreCase(name)))
6970
current = current.next;
7071
return current;
7172
}
@@ -92,7 +93,7 @@ public JsonValue require (int index) {
9293
* @throws IllegalArgumentException if the child was not found. */
9394
public JsonValue require (String name) {
9495
JsonValue current = child;
95-
while (current != null && !current.name.equalsIgnoreCase(name))
96+
while (current != null && (current.name == null || !current.name.equalsIgnoreCase(name)))
9697
current = current.next;
9798
if (current == null) throw new IllegalArgumentException("Child not found with name: " + name);
9899
return current;

0 commit comments

Comments
 (0)