Search in sources :

Example 21 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class JsonpCharacterEscapesTest method testGetEscapeSequenceTwo.

@Test
public void testGetEscapeSequenceTwo() {
    JsonpCharacterEscapes jsonpCharacterEscapes = JsonpCharacterEscapes.instance();
    assertEquals(new SerializedString("\\u2029"), jsonpCharacterEscapes.getEscapeSequence(0x2029));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) JsonpCharacterEscapes(com.fasterxml.jackson.core.util.JsonpCharacterEscapes) Test(org.junit.Test)

Example 22 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class NextXxxAccessTest method _testIsNextTokenName1.

/*
    /********************************************************
    /* Actual test code
    /********************************************************
     */
private void _testIsNextTokenName1(int mode) throws Exception {
    final String DOC = "{\"name\":123,\"name2\":14,\"x\":\"name\"}";
    JsonParser p = createParser(mode, DOC);
    final SerializedString NAME = new SerializedString("name");
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.START_OBJECT, p.currentToken());
    assertEquals(JsonTokenId.ID_START_OBJECT, p.currentTokenId());
    assertTrue(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals(NAME.getValue(), p.currentName());
    assertEquals(NAME.getValue(), p.getText());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_NUMBER_INT, p.currentToken());
    assertEquals(123, p.getIntValue());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("name2", p.currentName());
    assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
    // do NOT check number value, to enforce skipping
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("x", p.currentName());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_STRING, p.currentToken());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.END_OBJECT, p.currentToken());
    if (mode != MODE_DATA_INPUT) {
        assertFalse(p.nextFieldName(NAME));
        assertNull(p.currentToken());
    }
    p.close();
    // Actually, try again with slightly different sequence...
    p = createParser(mode, DOC);
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertFalse(p.nextFieldName(new SerializedString("Nam")));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals(NAME.getValue(), p.currentName());
    assertEquals(NAME.getValue(), p.getText());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_NUMBER_INT, p.currentToken());
    assertEquals(123, p.getIntValue());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("name2", p.currentName());
    assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("x", p.currentName());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_STRING, p.currentToken());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.END_OBJECT, p.currentToken());
    if (mode != MODE_DATA_INPUT) {
        assertFalse(p.nextFieldName(NAME));
        assertNull(p.currentToken());
    }
    p.close();
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Example 23 with SerializedString

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class NextXxxAccessTest method _testIsNextTokenName2.

private void _testIsNextTokenName2(int mode) throws Exception {
    final String DOC = "{\"name\":123,\"name2\":14,\"x\":\"name\"}";
    JsonParser p = createParser(mode, DOC);
    SerializableString NAME = new SerializedString("name");
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.START_OBJECT, p.currentToken());
    assertTrue(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals(NAME.getValue(), p.currentName());
    assertEquals(NAME.getValue(), p.getText());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_NUMBER_INT, p.currentToken());
    assertEquals(123, p.getIntValue());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("name2", p.currentName());
    assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.FIELD_NAME, p.currentToken());
    assertEquals("x", p.currentName());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.VALUE_STRING, p.currentToken());
    assertFalse(p.nextFieldName(NAME));
    assertToken(JsonToken.END_OBJECT, p.currentToken());
    if (mode != MODE_DATA_INPUT) {
        assertFalse(p.nextFieldName(NAME));
        assertNull(p.currentToken());
    }
    p.close();
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Aggregations

SerializedString (com.fasterxml.jackson.core.io.SerializedString)23 SerializableString (com.fasterxml.jackson.core.SerializableString)4 Test (org.junit.Test)4 JsonpCharacterEscapes (com.fasterxml.jackson.core.util.JsonpCharacterEscapes)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 CharacterEscapes (com.fasterxml.jackson.core.io.CharacterEscapes)1 UTF8DataInputJsonParser (com.fasterxml.jackson.core.json.UTF8DataInputJsonParser)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RawValue (com.fasterxml.jackson.databind.util.RawValue)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 BigDecimal (java.math.BigDecimal)1 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1