Search in sources :

Example 26 with JsonReader

use of android.util.JsonReader in project android_frameworks_base by crdroidandroid.

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);
    }
}
Also used : StringReader(java.io.StringReader) JsonReader(android.util.JsonReader) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

JsonReader (android.util.JsonReader)26 StringReader (java.io.StringReader)18 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 JSONException (org.json.JSONException)6 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)3 TargetApi (android.annotation.TargetApi)2 InputStreamReader (java.io.InputStreamReader)2 SuppressLint (android.annotation.SuppressLint)1 Uri (android.net.Uri)1 RealmException (io.realm.exceptions.RealmException)1 Table (io.realm.internal.Table)1 Scanner (java.util.Scanner)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1