diff --git a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java index df8bdb6d..55b6c6a8 100644 --- a/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java +++ b/faunaJava/src/main/java/com/fauna/serialization/FaunaParser.java @@ -166,8 +166,12 @@ private void handleStartObject() throws IOException { currentFaunaTokenType = FaunaTokenType.START_DOCUMENT; tokenStack.push(FaunaTokenType.START_DOCUMENT); break; - case REF_TAG: case SET_TAG: + advanceTrue(); + currentFaunaTokenType = FaunaTokenType.START_PAGE; + tokenStack.push(FaunaTokenType.START_PAGE); + break; + case REF_TAG: throw new SerializationException( "Token not implemented: " + jsonParser.getText()); default: diff --git a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java index ff7a1f5d..7d5d9cb5 100644 --- a/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java +++ b/faunaJava/src/test/java/com/fauna/serialization/FaunaParserTest.java @@ -325,6 +325,30 @@ public void testReadDocumentTokens() throws IOException { assertReader(reader, expectedTokens); } + @Test + public void testReadSet() throws IOException { + String s = "{\n" + + " \"@set\": {\n" + + " \"data\": [{\"@int\": \"99\"}],\n" + + " \"after\": \"afterme\"\n" + + " }\n" + + "}"; + FaunaParser reader = new FaunaParser(new ByteArrayInputStream(s.getBytes())); + + List> expectedTokens = List.of( + new AbstractMap.SimpleEntry<>(FaunaTokenType.START_PAGE, null), + Map.entry(FaunaTokenType.FIELD_NAME, "data"), + new AbstractMap.SimpleEntry<>(FaunaTokenType.START_ARRAY, null), + Map.entry(FaunaTokenType.INT, 99), + new AbstractMap.SimpleEntry<>(FaunaTokenType.END_ARRAY, null), + Map.entry(FaunaTokenType.FIELD_NAME, "after"), + Map.entry(FaunaTokenType.STRING, "afterme"), + new AbstractMap.SimpleEntry<>(FaunaTokenType.END_PAGE, null) + ); + + assertReader(reader, expectedTokens); + } + private static void assertReader(FaunaParser reader, List> tokens) throws IOException { for (Map.Entry entry : tokens) {