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));
}
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();
}
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();
}
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();
}
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();
}
Aggregations