use of android.util.JsonReader in project android_frameworks_base by crdroidandroid.
the class StatementParser method parseStatement.
/**
* Parses a single JSON statement.
*/
static ParsedStatement parseStatement(String statementString, AbstractAsset source) throws AssociationServiceException, IOException, JSONException {
JsonReader reader = new JsonReader(new StringReader(statementString));
reader.setLenient(false);
return parseStatement(reader, source);
}
use of android.util.JsonReader in project android_frameworks_base by AOSPA.
the class AbstractAsset method create.
/**
* Creates a new Asset from its JSON string representation.
*
* @throws AssociationServiceException if the assetJson is not well formatted.
*/
public static AbstractAsset create(String assetJson) throws AssociationServiceException {
JsonReader reader = new JsonReader(new StringReader(assetJson));
reader.setLenient(false);
try {
return AssetFactory.create(JsonParser.parse(reader));
} catch (JSONException | IOException e) {
throw new AssociationServiceException("Input is not a well formatted asset descriptor.", e);
}
}
use of android.util.JsonReader in project android_frameworks_base by AOSPA.
the class StatementParser method parseStatementList.
/**
* Parses a JSON array of statements.
*/
static ParsedStatement parseStatementList(String statementList, AbstractAsset source) throws JSONException, IOException {
List<Statement> statements = new ArrayList<Statement>();
List<String> delegates = new ArrayList<String>();
JsonReader reader = new JsonReader(new StringReader(statementList));
reader.setLenient(false);
reader.beginArray();
while (reader.hasNext()) {
ParsedStatement result;
try {
result = parseStatement(reader, source);
} catch (AssociationServiceException e) {
// The element in the array is well formatted Json but not a well-formed Statement.
continue;
}
statements.addAll(result.getStatements());
delegates.addAll(result.getDelegates());
}
reader.endArray();
return new ParsedStatement(statements, delegates);
}
use of android.util.JsonReader in project android_frameworks_base by AOSPA.
the class StatementParser method parseStatement.
/**
* Parses a single JSON statement.
*/
static ParsedStatement parseStatement(String statementString, AbstractAsset source) throws AssociationServiceException, IOException, JSONException {
JsonReader reader = new JsonReader(new StringReader(statementString));
reader.setLenient(false);
return parseStatement(reader, source);
}
use of android.util.JsonReader in project android_frameworks_base by DirtyUnicorns.
the class StatementParser method parseStatementList.
/**
* Parses a JSON array of statements.
*/
static ParsedStatement parseStatementList(String statementList, AbstractAsset source) throws JSONException, IOException {
List<Statement> statements = new ArrayList<Statement>();
List<String> delegates = new ArrayList<String>();
JsonReader reader = new JsonReader(new StringReader(statementList));
reader.setLenient(false);
reader.beginArray();
while (reader.hasNext()) {
ParsedStatement result;
try {
result = parseStatement(reader, source);
} catch (AssociationServiceException e) {
// The element in the array is well formatted Json but not a well-formed Statement.
continue;
}
statements.addAll(result.getStatements());
delegates.addAll(result.getDelegates());
}
reader.endArray();
return new ParsedStatement(statements, delegates);
}
Aggregations