diff --git a/src/main/java/net/openhft/chronicle/wire/JSONWire.java b/src/main/java/net/openhft/chronicle/wire/JSONWire.java index e56865c697..4f6874e48b 100644 --- a/src/main/java/net/openhft/chronicle/wire/JSONWire.java +++ b/src/main/java/net/openhft/chronicle/wire/JSONWire.java @@ -891,6 +891,7 @@ private Object parseType() throws InvalidMarshallableException { final Class clazz = classLookup().forName(sb.subSequence(1, sb.length())); Object object = parseType(null, clazz, true); consume('}'); + consumePadding(1); return object; } } diff --git a/src/test/java/net/openhft/chronicle/wire/issue/Issue844Test.java b/src/test/java/net/openhft/chronicle/wire/issue/Issue844Test.java new file mode 100644 index 0000000000..b69f1be422 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/wire/issue/Issue844Test.java @@ -0,0 +1,48 @@ +package net.openhft.chronicle.wire.issue; + +import net.openhft.chronicle.wire.WireTestCommon; +import net.openhft.chronicle.wire.WireType; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class Issue844Test extends WireTestCommon { + + @Test + public void nestedMapsJson() { + + // at least 3 levels of nested to reproduce this issue + Object o2 = WireType.JSON_ONLY.fromString("\"serviceConfig\": {\n" + + " \"db\": {\n" + + " \"a\": {\n" + + " \"Hello\": \"World\"\n" + + " },\n" + + " \"mongodb\": {\n" + + " \"@net.openhft.chronicle.wire.issue.Issue844Test$Enum\": \"INSTANCE\"\n" + + " },\n" + + " \"collection\": \"ladder\"\n" + + " }\n" + + "}"); + assertEquals( + "serviceConfig: {\n" + + " db: {\n" + + " a: {\n" + + " Hello: World\n" + + " },\n" + + " mongodb: !net.openhft.chronicle.wire.issue.Issue844Test$Enum INSTANCE,\n" + + " collection: ladder\n" + + " }\n" + + "}\n", + WireType.YAML_ONLY.asString(o2)); + assertEquals( + "{\"serviceConfig\":{\"db\":{\"a\":{\"Hello\":\"World\"},\"mongodb\":{\"@net.openhft.chronicle.wire.issue.Issue844Test$Enum\":\"INSTANCE\"},\"collection\":\"ladder\"}}}", + WireType.JSON_ONLY.asString(o2) + ); + } + + + public enum Enum { + INSTANCE + } + +}