use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project keycloak by keycloak.
the class RealmsConfigurationLoader method readUsers.
private static void readUsers(RealmRepresentation r, JsonParser p) throws IOException {
JsonToken t = p.nextToken();
if (t != JsonToken.START_ARRAY) {
throw new RuntimeException("Error reading field 'users'. Expected array of users [" + t + "]");
}
t = p.nextToken();
while (t == JsonToken.START_OBJECT) {
UserRepresentation u = p.readValueAs(UserRepresentation.class);
if (!started && userSkipped(u.getUsername())) {
log.info("User skipped: " + u.getUsername());
} else {
enqueueCreateUser(r, u);
}
t = p.nextToken();
currentUser += 1;
// in order to short-circuit if any errors have occurred
if (currentUser % ERROR_CHECK_INTERVAL == 0) {
checkPendingErrors(u.getUsername());
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportXlsxRenderer method getJsonNodeByName.
/**
* Methods is intended to read JSON values of the renderer source file specified by its name.
* This method searches for a field name and returns token with its value.
* The parser is able to go through the input stream one way only.
* Field names HAVE TO be searched in the same order they were written.
*/
JsonToken getJsonNodeByName(JsonParser jParser, String propertyName) {
JsonToken token = null;
try {
do {
String name = jParser.currentName();
if (StringUtils.equals(name, ChangesOnSystemReportExecutor.ATTRIBUTE_NAME_JSON_KEY) && StringUtils.equals(propertyName, ChangesOnSystemReportExecutor.ATTRIBUTE_NAME_JSON_KEY)) {
token = jParser.nextToken();
if (token == JsonToken.START_ARRAY) {
return token;
} else {
return null;
}
} else if (StringUtils.equals(name, ChangesOnSystemReportExecutor.RECORDS_JSON_KEY) && StringUtils.equals(propertyName, ChangesOnSystemReportExecutor.RECORDS_JSON_KEY)) {
// skip to the start of array
token = jParser.nextToken();
do {
if (token == JsonToken.START_OBJECT) {
return token;
}
token = jParser.nextToken();
} while (token != JsonToken.END_ARRAY);
return null;
} else if (name != null) {
token = jParser.nextToken();
if (token == JsonToken.START_OBJECT || token == JsonToken.START_ARRAY) {
jParser.skipChildren();
}
}
token = jParser.nextToken();
} while (!jParser.isClosed());
} catch (Exception e) {
return null;
}
return token;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project Payara by payara.
the class ProgressStatusEventJsonProprietaryReader method readFrom.
@Override
public ProgressStatusEvent readFrom(final InputStream is, final String contentType) throws IOException {
try (JsonParser jp = factory.createJsonParser(is)) {
// sorounding object
JsonToken token = jp.nextToken();
// Name progress-status-event
jp.nextToken();
JsonToken token2 = jp.nextToken();
if (token != JsonToken.START_OBJECT || token2 != JsonToken.START_OBJECT || !"progress-status-event".equals(jp.getCurrentName())) {
throw new IOException("Not expected type (progress-status-event) but (" + jp.getCurrentName() + ")");
}
return readProgressStatusEvent(jp);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project Payara by payara.
the class ProgressStatusDTOJsonProprietaryReader method readFrom.
@Override
public ProgressStatusDTO readFrom(final InputStream is, final String contentType) throws IOException {
try (JsonParser jp = factory.createJsonParser(is)) {
// sorounding object
JsonToken token = jp.nextToken();
// Name progress-status
jp.nextToken();
JsonToken token2 = jp.nextToken();
if (token != JsonToken.START_OBJECT || token2 != JsonToken.START_OBJECT || !"progress-status".equals(jp.getCurrentName())) {
throw new IOException("Not expected type (progress-status) but (" + jp.getCurrentName() + ")");
}
return readProgressStatus(jp);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonToken in project navajo by Dexels.
the class JSONTest method simpleTest.
@Test
public void simpleTest() throws IOException {
byte[] json_chunk1 = "{\"name\":\"El".getBytes(StandardCharsets.UTF_8);
byte[] json_chunk2 = "vis\"}".getBytes(StandardCharsets.UTF_8);
JsonFactory s = new JsonFactory();
// NonBlockingJsonParser n = new NonBlockingJsonParser();
// s.createNonBlockingByteArrayParser().getNonBlockingInputFeeder().
NonBlockingJsonParser nbj = ((NonBlockingJsonParser) s.createNonBlockingByteArrayParser());
nbj.feedInput(json_chunk1, 0, json_chunk1.length);
JsonToken t = null;
do {
t = nbj.nextToken();
System.err.println("t: " + t);
} while (t != null && t != JsonToken.NOT_AVAILABLE);
nbj.feedInput(json_chunk2, 0, json_chunk2.length);
// nbj.endOfInput();
do {
t = nbj.nextToken();
System.err.println("t: " + t);
} while (t != null && t != JsonToken.NOT_AVAILABLE);
}
Aggregations