Search in sources :

Example 16 with JsonReader

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

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)

Example 17 with JsonReader

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

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

Example 18 with JsonReader

use of android.util.JsonReader in project DrupalCloud by INsReady.

the class RESTServerClient method viewsGet.

/*
	 * public String userLogout(String sessionID) throws
	 * ServiceNotAvailableException { // TODO Auto-generated method stub
	 * BasicNameValuePair[] parameters = new BasicNameValuePair[0]; //
	 * parameters[0] = new BasicNameValuePair("sessid", sessionID); String uri =
	 * mENDPOIN + "user/logout"; return call(uri, parameters); }
	 */
public JsonReader viewsGet(String view_name, String display_id, String args, int offset, int limit) throws ServiceNotAvailableException, ClientProtocolException, IOException {
    String uri = mENDPOIN + "views/" + view_name + "?" + "limit=" + limit + "&offset=" + offset;
    if (args != null) {
        uri += "&args=" + args;
    }
    if (display_id != null) {
        uri += "&display_id=" + display_id;
    }
    JsonReader result = new JsonReader(callGet(uri));
    return result;
}
Also used : JsonReader(android.util.JsonReader)

Example 19 with JsonReader

use of android.util.JsonReader in project DrupalCloud by INsReady.

the class RESTServerClient method nodeGet.

/*
	 * private void systemConnect() throws ServiceNotAvailableException { //
	 * Cloud server hand shake String uri = mENDPOIN + "system/connect";
	 * mSERVERPOST = new HttpPost(uri); try { HttpResponse response =
	 * mClient.execute(mSERVERPOST); InputStream result =
	 * response.getEntity().getContent(); BufferedReader br = new
	 * BufferedReader( new InputStreamReader(result)); String tmp =
	 * br.readLine(); if (tmp == null) { // TODO throw new
	 * ServiceNotAvailableException(this, // "Invalid method"); } JSONObject jso
	 * = new JSONObject(tmp); // Save the sessionid to storage SharedPreferences
	 * auth = mCtx.getSharedPreferences(mPREFS_AUTH, 0);
	 * SharedPreferences.Editor editor = auth.edit();
	 * editor.putString("sessionid", jso.getString("sessid"));
	 * editor.putLong("sessionid_timestamp", new Date().getTime() / 100);
	 * editor.commit();
	 * 
	 * } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch
	 * (ClientProtocolException e) { e.printStackTrace(); } catch (IOException
	 * e) { e.printStackTrace(); } catch (JSONException e) { // TODO
	 * Auto-generated catch block e.printStackTrace(); } }
	 */
public JsonReader nodeGet(int nid, String fields) throws ServiceNotAvailableException, ClientProtocolException, IOException {
    String uri = mENDPOIN + "node/" + nid;
    JsonReader jsr = new JsonReader(callGet(uri));
    return jsr;
}
Also used : JsonReader(android.util.JsonReader)

Example 20 with JsonReader

use of android.util.JsonReader in project DrupalCloud by INsReady.

the class RESTServerClient method taxonomyVocabGetTree.

public JsonReader taxonomyVocabGetTree(int vid, int parent, int maxdepth) throws ServiceNotAvailableException, ClientProtocolException, IOException {
    String uri = mENDPOIN + "taxonomy_vocabulary/getTree";
    int size = 2;
    BasicNameValuePair[] parameters = null;
    if (maxdepth != 0) {
        size = 3;
        parameters = new BasicNameValuePair[size];
        parameters[2] = new BasicNameValuePair("maxdepth", String.valueOf(maxdepth));
    } else {
        parameters = new BasicNameValuePair[size];
    }
    parameters[0] = new BasicNameValuePair("vid", String.valueOf(vid));
    parameters[1] = new BasicNameValuePair("parent", String.valueOf(parent));
    JsonReader jsr = new JsonReader(callPost(uri, parameters));
    return jsr;
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) JsonReader(android.util.JsonReader) SuppressLint(android.annotation.SuppressLint)

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