use of 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 com.fasterxml.jackson.core.JsonParser in project orientdb by orientechnologies.
the class OGraphSONUtility method vertexFromJson.
/**
* Creates a vertex from GraphSON using settings supplied in the constructor.
*/
public Vertex vertexFromJson(final InputStream json) throws IOException {
final JsonParser jp = jsonFactory.createParser(json);
final JsonNode node = jp.readValueAsTree();
return this.vertexFromJson(node);
}
use of com.fasterxml.jackson.core.JsonParser in project presto by prestodb.
the class JsonFunctions method jsonArrayContains.
@SqlNullable
@ScalarFunction
@SqlType(StandardTypes.BOOLEAN)
public static Boolean jsonArrayContains(@SqlType(StandardTypes.JSON) Slice json, @SqlType(StandardTypes.BOOLEAN) boolean value) {
try (JsonParser parser = createJsonParser(JSON_FACTORY, json)) {
if (parser.nextToken() != START_ARRAY) {
return null;
}
while (true) {
JsonToken token = parser.nextToken();
if (token == null) {
return null;
}
if (token == END_ARRAY) {
return false;
}
parser.skipChildren();
if (((token == VALUE_TRUE) && value) || ((token == VALUE_FALSE) && (!value))) {
return true;
}
}
} catch (IOException e) {
return null;
}
}
use of com.fasterxml.jackson.core.JsonParser in project presto by prestodb.
the class JsonFunctions method jsonArrayLength.
@SqlNullable
@ScalarFunction
@SqlType(StandardTypes.BIGINT)
public static Long jsonArrayLength(@SqlType(StandardTypes.JSON) Slice json) {
try (JsonParser parser = createJsonParser(JSON_FACTORY, json)) {
if (parser.nextToken() != START_ARRAY) {
return null;
}
long length = 0;
while (true) {
JsonToken token = parser.nextToken();
if (token == null) {
return null;
}
if (token == END_ARRAY) {
return length;
}
parser.skipChildren();
length++;
}
} catch (IOException e) {
return null;
}
}
use of com.fasterxml.jackson.core.JsonParser in project presto by prestodb.
the class JsonFunctions method jsonArrayContains.
@SqlNullable
@ScalarFunction
@SqlType(StandardTypes.BOOLEAN)
public static Boolean jsonArrayContains(@SqlType(StandardTypes.JSON) Slice json, @SqlType(StandardTypes.BIGINT) long value) {
try (JsonParser parser = createJsonParser(JSON_FACTORY, json)) {
if (parser.nextToken() != START_ARRAY) {
return null;
}
while (true) {
JsonToken token = parser.nextToken();
if (token == null) {
return null;
}
if (token == END_ARRAY) {
return false;
}
parser.skipChildren();
if ((token == VALUE_NUMBER_INT) && ((parser.getNumberType() == NumberType.INT) || (parser.getNumberType() == NumberType.LONG)) && (parser.getLongValue() == value)) {
return true;
}
}
} catch (IOException e) {
return null;
}
}
Aggregations