Search in sources :

Example 96 with JsonFactory

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

the class TestPrettyPrinter method testCustomRootSeparatorWithFactory.

// Alternative solution for [jackson-core#26]
public void testCustomRootSeparatorWithFactory() throws Exception {
    JsonFactory f = JsonFactory.builder().rootValueSeparator("##").build();
    StringWriter sw = new StringWriter();
    JsonGenerator gen = f.createGenerator(ObjectWriteContext.empty(), sw);
    gen.writeNumber(13);
    gen.writeBoolean(false);
    gen.writeNull();
    gen.close();
    assertEquals("13##false##null", sw.toString());
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 97 with JsonFactory

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

the class CommentParsingTest method testCCommentsChars.

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

Example 98 with JsonFactory

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

the class CommentParsingTest method _createParser.

private JsonParser _createParser(String doc, int mode, boolean enabled) throws IOException {
    JsonFactory f = JsonFactory.builder().configure(JsonParser.Feature.ALLOW_COMMENTS, enabled).build();
    JsonParser p = createParser(f, mode, doc);
    assertToken(JsonToken.START_ARRAY, p.nextToken());
    return p;
}
Also used : JsonFactory(com.fasterxml.jackson.core.json.JsonFactory)

Example 99 with JsonFactory

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

the class CommentParsingTest method testCppCommentsBytes.

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

Example 100 with JsonFactory

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

the class CommentParsingTest method testCCommentsBytes.

public void testCCommentsBytes() throws Exception {
    JsonFactory f = JsonFactory.builder().enable(JsonParser.Feature.ALLOW_COMMENTS).build();
    final String COMMENT = "/* foo */\n";
    _testCommentsBeforePropValue(f, MODE_INPUT_STREAM, COMMENT);
    _testCommentsBeforePropValue(f, MODE_INPUT_STREAM_THROTTLED, COMMENT);
    _testCommentsBeforePropValue(f, MODE_DATA_INPUT, COMMENT);
}
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