Search in sources :

Example 21 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.

the class UnwrappingBeanPropertyWriter method rename.

@Override
public UnwrappingBeanPropertyWriter rename(NameTransformer transformer) {
    String oldName = _name.getValue();
    String newName = transformer.transform(oldName);
    // important: combine transformers:
    transformer = NameTransformer.chainedTransformer(transformer, _nameTransformer);
    return _new(transformer, new SerializedString(newName));
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Example 22 with SerializedString

use of 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.nextName(NAME));
    assertToken(JsonToken.START_OBJECT, p.currentToken());
    assertTrue(p.nextName(NAME));
    assertToken(JsonToken.PROPERTY_NAME, p.currentToken());
    assertEquals(NAME.getValue(), p.currentName());
    assertEquals(NAME.getValue(), p.getText());
    assertFalse(p.nextName(NAME));
    assertToken(JsonToken.VALUE_NUMBER_INT, p.currentToken());
    assertEquals(123, p.getIntValue());
    assertFalse(p.nextName(NAME));
    assertToken(JsonToken.PROPERTY_NAME, p.currentToken());
    assertEquals("name2", p.currentName());
    assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
    assertFalse(p.nextName(NAME));
    assertToken(JsonToken.PROPERTY_NAME, p.currentToken());
    assertEquals("x", p.currentName());
    assertFalse(p.nextName(NAME));
    assertToken(JsonToken.VALUE_STRING, p.currentToken());
    assertFalse(p.nextName(NAME));
    assertToken(JsonToken.END_OBJECT, p.currentToken());
    if (mode != MODE_DATA_INPUT) {
        assertFalse(p.nextName(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 com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class NextXxxAccessTest method _testIssue34.

private void _testIssue34(int mode) throws Exception {
    final int TESTROUNDS = 223;
    final String DOC_PART = "{ \"fieldName\": 1 }";
    // build the big document to trigger issue
    StringBuilder sb = new StringBuilder(2000);
    for (int i = 0; i < TESTROUNDS; ++i) {
        sb.append(DOC_PART);
    }
    final String DOC = sb.toString();
    SerializableString fieldName = new SerializedString("fieldName");
    JsonParser parser = createParser(mode, DOC);
    for (int i = 0; i < TESTROUNDS - 1; i++) {
        assertEquals(JsonToken.START_OBJECT, parser.nextToken());
        // These will succeed
        assertTrue(parser.nextName(fieldName));
        parser.nextLongValue(-1);
        assertEquals(JsonToken.END_OBJECT, parser.nextToken());
    }
    assertEquals(JsonToken.START_OBJECT, parser.nextToken());
    // This will fail
    assertTrue(parser.nextName(fieldName));
    parser.close();
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Example 24 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class NextXxxAccessTest method _testIsNextTokenName5.

private void _testIsNextTokenName5(int mode) throws Exception {
    final String DOC = "{\"name\":\t\r{ },\"name2\":null}";
    JsonParser p = createParser(mode, DOC);
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertTrue(p.nextName(new SerializedString("name")));
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    assertTrue(p.nextName(new SerializedString("name2")));
    assertToken(JsonToken.VALUE_NULL, p.nextToken());
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    if (mode != MODE_DATA_INPUT) {
        assertNull(p.nextToken());
    }
    p.close();
}
Also used : SerializedString(com.fasterxml.jackson.core.io.SerializedString) SerializedString(com.fasterxml.jackson.core.io.SerializedString)

Example 25 with SerializedString

use of com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.

the class NextXxxAccessTest method _testNextFieldNameIndent.

private void _testNextFieldNameIndent(int mode) throws Exception {
    final String DOC = "{\n  \"name\" : \n  [\n  ]\n   }";
    JsonParser p = createParser(mode, DOC);
    assertToken(JsonToken.START_OBJECT, p.nextToken());
    assertTrue(p.nextName(new SerializedString("name")));
    assertToken(JsonToken.START_ARRAY, p.nextToken());
    assertFalse(p.nextName(new SerializedString("x")));
    assertToken(JsonToken.END_ARRAY, p.currentToken());
    assertToken(JsonToken.END_OBJECT, p.nextToken());
    if (mode != MODE_DATA_INPUT) {
        assertNull(p.nextToken());
    }
    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)34 SerializableString (com.fasterxml.jackson.core.SerializableString)4 Test (org.junit.Test)4 JsonpCharacterEscapes (com.fasterxml.jackson.core.util.JsonpCharacterEscapes)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 CharacterEscapes (com.fasterxml.jackson.core.io.CharacterEscapes)1 UTF8DataInputJsonParser (com.fasterxml.jackson.core.json.UTF8DataInputJsonParser)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 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 IndexTemplate (org.apache.skywalking.library.elasticsearch.response.IndexTemplate)1 IndexTemplates (org.apache.skywalking.library.elasticsearch.response.IndexTemplates)1