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