Search in sources :

Example 46 with JsonFactory

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

the class AsyncStringArrayTest method testLongAsciiStrings.

public void testLongAsciiStrings() throws IOException {
    final String[] input = new String[] { // ~100 chars for long(er) content
    String.format("%s %s %s %s %s %s %s %s %s %s %s %s", str0to9, str0to9, "...", str0to9, "/", str0to9, str0to9, "", str0to9, str0to9, "...", str0to9), LONG_ASCII };
    JsonFactory f = JSON_F;
    byte[] data = _stringDoc(f, input);
    // first: require headers, no offsets
    _testStrings(f, input, data, 0, 9000);
    _testStrings(f, input, data, 0, 1);
    _testStrings(f, input, data, 0, 3);
    // then with some offsets:
    _testStrings(f, input, data, 1, 9000);
    _testStrings(f, input, data, 1, 3);
    _testStrings(f, input, data, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 47 with JsonFactory

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

the class AsyncNonStdParsingTest method testNonStandardNameChars.

public void testNonStandardNameChars() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES).build();
    _testNonStandardNameChars(f, 0, 99);
    _testNonStandardNameChars(f, 0, 6);
    _testNonStandardNameChars(f, 0, 3);
    _testNonStandardNameChars(f, 0, 1);
    _testNonStandardNameChars(f, 1, 99);
    _testNonStandardNameChars(f, 2, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 48 with JsonFactory

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

the class AsyncNonStdParsingTest method testSingleQuotesEscaped.

// test to verify that we implicitly allow escaping of apostrophe
public void testSingleQuotesEscaped() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES).build();
    _testSingleQuotesEscaped(f, 0, 99);
    _testSingleQuotesEscaped(f, 0, 5);
    _testSingleQuotesEscaped(f, 0, 3);
    _testSingleQuotesEscaped(f, 0, 1);
    _testSingleQuotesEscaped(f, 1, 99);
    _testSingleQuotesEscaped(f, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 49 with JsonFactory

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

the class AsyncNonStdParsingTest method testAposQuotingEnabled.

/**
 * Test to verify optional handling of
 * single quotes, to allow handling invalid (but, alas, common)
 * JSON.
 */
public void testAposQuotingEnabled() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES).build();
    _testAposQuotingEnabled(f, 0, 99);
    _testAposQuotingEnabled(f, 0, 5);
    _testAposQuotingEnabled(f, 0, 3);
    _testAposQuotingEnabled(f, 0, 2);
    _testAposQuotingEnabled(f, 0, 1);
    _testAposQuotingEnabled(f, 1, 99);
    _testAposQuotingEnabled(f, 2, 1);
    _testAposQuotingEnabled(f, 1, 1);
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 50 with JsonFactory

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

the class AsyncNonStdParsingTest method _testNonStandarBackslashQuoting.

private void _testNonStandarBackslashQuoting(int offset, int readSize) throws Exception {
    // first: verify that we get an exception
    JsonFactory f = new JsonFactory();
    assertFalse(f.isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
    final String JSON = quote("\\'");
    AsyncReaderWrapper p = createParser(f, JSON, offset, readSize);
    try {
        p.nextToken();
        p.currentText();
        fail("Should have thrown an exception for doc <" + JSON + ">");
    } catch (JsonParseException e) {
        verifyException(e, "unrecognized character escape");
    } finally {
        p.close();
    }
    // and then verify it's ok...
    f = f.rebuild().enable(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER).build();
    assertTrue(f.isEnabled(JsonParser.Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER));
    p = createParser(f, JSON, offset, readSize);
    assertToken(JsonToken.VALUE_STRING, p.nextToken());
    assertEquals("'", p.currentText());
    p.close();
}
Also used : AsyncReaderWrapper(com.fasterxml.jackson.core.testsupport.AsyncReaderWrapper) 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