Search in sources :

Example 51 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncCommentParsingTest method testYAMLCommentsEnabled.

public void testYAMLCommentsEnabled() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_YAML_COMMENTS).build();
    _testYAMLComments(f, 99);
    _testYAMLComments(f, 3);
    _testYAMLComments(f, 1);
    _testCommentsBeforePropValue(f, "# foo\n", 99);
    _testCommentsBeforePropValue(f, "# foo\n", 3);
    _testCommentsBeforePropValue(f, "# foo\n", 1);
    _testCommentsBetweenArrayValues(f, "# foo\n", 99);
    _testCommentsBetweenArrayValues(f, "# foo\n", 3);
    _testCommentsBetweenArrayValues(f, "# foo\n", 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 52 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class AsyncCommentParsingTest method testCppCommentsEnabled.

public void testCppCommentsEnabled() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_COMMENTS).build();
    final String COMMENT = "// foo\n";
    _testCommentsBeforePropValue(f, COMMENT, 99);
    _testCommentsBeforePropValue(f, COMMENT, 3);
    _testCommentsBeforePropValue(f, COMMENT, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 53 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class JsonParserTest method _testIntern.

private void _testIntern(boolean useStream, boolean enableIntern, String expName) throws IOException {
    JsonFactory f = JsonFactory.builder().configure(JsonFactory.Feature.INTERN_FIELD_NAMES, enableIntern).build();
    assertEquals(enableIntern, f.isEnabled(JsonFactory.Feature.INTERN_FIELD_NAMES));
    final String JSON = "{ \"" + expName + "\" : 1}";
    JsonParser p = useStream ? createParserUsingStream(f, JSON, "UTF-8") : createParserUsingReader(f, JSON);
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertToken(JsonToken.FIELD_NAME, p.nextToken());
    // needs to be same of cours
    String actName = p.currentName();
    assertEquals(expName, actName);
    if (enableIntern) {
        assertSame(expName, actName);
    } else {
        assertNotSame(expName, actName);
    }
    p.close();
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 54 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class ParserDupHandlingTest method testSimpleDupsChars.

public void testSimpleDupsChars() throws Exception {
    JsonFactory nonDupF = new JsonFactory();
    JsonFactory dupF = JsonFactory.builder().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION).build();
    for (String doc : DUP_DOCS) {
        _testSimpleDupsFail(doc, dupF, MODE_READER, "a", false);
        _testSimpleDupsFail(doc, nonDupF, MODE_READER, "a", true);
    }
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 55 with JsonFactory

use of com.fasterxml.jackson.core.json.JsonFactory in project jackson-core by FasterXML.

the class ParserDupHandlingTest method testSimpleDupsBytes.

public void testSimpleDupsBytes() throws Exception {
    JsonFactory nonDupF = new JsonFactory();
    JsonFactory dupF = JsonFactory.builder().enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION).build();
    for (String doc : DUP_DOCS) {
        // First, with static setting
        _testSimpleDupsFail(doc, dupF, MODE_INPUT_STREAM, "a", false);
        // and then dynamic
        _testSimpleDupsFail(doc, nonDupF, MODE_INPUT_STREAM, "a", true);
        _testSimpleDupsFail(doc, dupF, MODE_INPUT_STREAM_THROTTLED, "a", false);
        _testSimpleDupsFail(doc, nonDupF, MODE_INPUT_STREAM_THROTTLED, "a", true);
    }
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Aggregations

JsonFactory (com.fasterxml.jackson.core.json.JsonFactory)137 AsyncReaderWrapper (com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper)5 DefaultPrettyPrinter (com.fasterxml.jackson.core.util.DefaultPrettyPrinter)3 JsonParser (com.fasterxml.jackson.core.JsonParser)2 SerializedString (com.fasterxml.jackson.core.io.SerializedString)2 NonBlockingJsonParserBase (com.fasterxml.jackson.core.json.async.NonBlockingJsonParserBase)2 ByteQuadsCanonicalizer (com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer)2 MinimalPrettyPrinter (com.fasterxml.jackson.core.util.MinimalPrettyPrinter)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BigDecimal (java.math.BigDecimal)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 StringWriter (java.io.StringWriter)1 Field (java.lang.reflect.Field)1 BigInteger (java.math.BigInteger)1 HashSet (java.util.HashSet)1