use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project openhab1-addons by openhab.
the class JsonWeatherParser method parseInto.
/**
* {@inheritDoc}
*/
@Override
public void parseInto(InputStream is, Weather weather) throws Exception {
JsonFactory jsonFactory = new JsonFactory();
JsonParser jp = jsonFactory.createParser(is);
jp.nextValue();
handleToken(jp, null, weather);
jp.close();
super.parseInto(is, weather);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project midpoint by Evolveum.
the class AbstractJsonLexicalProcessor method parseFromStart.
@NotNull
private RootXNode parseFromStart(JsonParser unconfiguredParser, ParsingContext parsingContext) throws SchemaException {
JsonParsingContext ctx = null;
try {
JsonParser parser = configureParser(unconfiguredParser);
parser.nextToken();
if (parser.currentToken() == null) {
throw new SchemaException("Nothing to parse: the input is empty.");
}
ctx = new JsonParsingContext(parser, parsingContext);
XNode xnode = parseValue(ctx);
if (!(xnode instanceof MapXNode) || ((MapXNode) xnode).size() != 1) {
throw new SchemaException("Expected MapXNode with a single key; got " + xnode + " instead. At " + getPositionSuffix(ctx));
}
processDefaultNamespaces(xnode, null, ctx);
processSchemaNodes(xnode);
Entry<QName, XNode> entry = ((MapXNode) xnode).entrySet().iterator().next();
RootXNode root = new RootXNode(entry.getKey(), entry.getValue());
if (entry.getValue() != null) {
// TODO - ok ????
root.setTypeQName(entry.getValue().getTypeQName());
}
return root;
} catch (IOException e) {
throw new SchemaException("Cannot parse JSON/YAML object: " + e.getMessage() + (ctx != null ? " At: " + getPositionSuffix(ctx) : ""), e);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project OpenAM by OpenRock.
the class RestSTSInstanceConfigTest method testJsonStringMarshalling.
@Test
public void testJsonStringMarshalling() throws IOException {
RestSTSInstanceConfig origConfig = createInstanceConfig("/bob", WITH_TLS_OFFLOAD_CONFIG, WITH_SAML2_CONFIG, WITH_OIDC_CONFIG, WITH_CUSTOM_VALIDATOR, WITH_CUSTOM_PROVIDER, WITH_CTS_TOKEN_PERSISTENCE);
/*
This is how the Crest HttpServletAdapter ultimately constitutes a JsonValue from a json string. See the
org.forgerock.json.resource.servlet.HttpUtils.parseJsonBody (called from HttpServletAdapter.getJsonContent)
for details.
*/
JsonParser parser = new ObjectMapper().getFactory().createParser(origConfig.toJson().toString());
final Object content = parser.readValueAs(Object.class);
assertEquals(origConfig, RestSTSInstanceConfig.fromJson(new JsonValue(content)));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project OpenAM by OpenRock.
the class SoapSTSInstanceConfigTest method testJsonStringMarshalling.
@Test
public void testJsonStringMarshalling() throws IOException {
SoapSTSInstanceConfig origConfig = createInstanceConfig("/bobo/instance1", "http://host.com:8080/am", WITH_KEYSTORE_CONFIG, WITH_VALIDATE_CONFIG, DELEGATION_VALIDATORS_SPECIFIED, CUSTOM_DELEGATION_HANDLER, WITH_SAML2_CONFIG, WITH_OIDC_CONFIG, !WITH_CTS_TOKEN_PERSISTENCE);
/*
This is how the Crest HttpServletAdapter ultimately constitutes a JsonValue from a json string. See the
org.forgerock.json.resource.servlet.HttpUtils.parseJsonBody (called from HttpServletAdapter.getJsonContent)
for details.
*/
JsonParser parser = new ObjectMapper().getFactory().createParser(origConfig.toJson().toString());
final Object content = parser.readValueAs(Object.class);
assertEquals(origConfig, SoapSTSInstanceConfig.fromJson(new JsonValue(content)));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser in project jackson-core by FasterXML.
the class ValueConversionsTest method _testAsInt.
private void _testAsInt(int mode) throws Exception {
final String input = "[ 1, -3, 4.98, true, false, null, \"-17\", \"foo\" ]";
JsonParser p = createParser(mode, input);
assertToken(JsonToken.START_ARRAY, p.nextToken());
assertEquals(0, p.getValueAsLong());
assertEquals(9, p.getValueAsLong(9));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(1, p.getValueAsLong());
assertEquals(1, p.getValueAsLong(-99));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(-3, p.getValueAsLong());
assertToken(JsonToken.VALUE_NUMBER_FLOAT, p.nextToken());
assertEquals(4, p.getValueAsLong());
assertEquals(4, p.getValueAsLong(99));
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertEquals(1, p.getValueAsLong());
assertToken(JsonToken.VALUE_FALSE, p.nextToken());
assertEquals(0, p.getValueAsLong());
assertToken(JsonToken.VALUE_NULL, p.nextToken());
assertEquals(0, p.getValueAsLong());
assertEquals(0, p.getValueAsLong(27));
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(-17, p.getValueAsLong());
assertEquals(-17, p.getValueAsLong(3));
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals(0, p.getValueAsLong());
assertEquals(9, p.getValueAsLong(9));
assertToken(JsonToken.END_ARRAY, p.nextToken());
assertEquals(0, p.getValueAsLong());
assertEquals(9, p.getValueAsLong(9));
p.close();
}
Aggregations