use of android.util.JsonReader in project DrupalCloud by INsReady.
the class RESTServerClient method userLogin.
/*
* public boolean flagFlag(String flagName, int contentId, int uid, boolean
* action, boolean skipPermissionCheck) throws ServiceNotAvailableException
* { String uri = mENDPOIN + "flag/flag"; BasicNameValuePair[] parameters =
* new BasicNameValuePair[5]; parameters[0] = new
* BasicNameValuePair("flag_name", flagName); parameters[1] = new
* BasicNameValuePair("content_id", String.valueOf(contentId));
* parameters[2] = new BasicNameValuePair("uid", String.valueOf(uid));
* String actionName = (action) ? "flag" : "unflag"; parameters[3] = new
* BasicNameValuePair("action", actionName); String skipPermissionCheckName
* = (skipPermissionCheck) ? "TRUE" : "FALSE"; parameters[4] = new
* BasicNameValuePair("skip_permission_check", skipPermissionCheckName);
* //String result = call(uri, parameters); JSONObject jso; try { jso = new
* JSONObject(result); boolean flag = jso.getBoolean("#data"); return flag;
* } catch (JSONException e) { e.printStackTrace(); } return false; }
*/
/*
* public boolean flagIsFlagged(String flagName, int contentId, int uid)
* throws ServiceNotAvailableException { String uri = mENDPOIN +
* "flag/flag_isflaged"; BasicNameValuePair[] parameters = new
* BasicNameValuePair[3]; parameters[0] = new
* BasicNameValuePair("flag_name", flagName); parameters[1] = new
* BasicNameValuePair("content_id", String.valueOf(contentId));
* parameters[2] = new BasicNameValuePair("uid", String.valueOf(uid));
* String result = call(uri, parameters);
*
* JSONObject jso; try { jso = new JSONObject(result); boolean flag =
* jso.getBoolean(""); return flag; } catch (JSONException e) {
* e.printStackTrace(); } return false; }
*/
public JsonReader userLogin(String username, String password) throws ServiceNotAvailableException, IOException {
String uri = mENDPOIN + "user/login";
BasicNameValuePair[] parameters = new BasicNameValuePair[2];
parameters[0] = new BasicNameValuePair("username", username);
parameters[1] = new BasicNameValuePair("password", password);
JsonReader jsr = new JsonReader(callPost(uri, parameters));
return jsr;
}
use of android.util.JsonReader in project platform_frameworks_base by android.
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_packages_inputmethods_LatinIME by CyanogenMod.
the class MetadataParser method parseMetadata.
/**
* Parses metadata in the JSON format.
* @param input a stream reader expected to contain JSON formatted metadata.
* @return dictionary metadata, as an array of WordListMetadata objects.
* @throws IOException if the underlying reader throws IOException during reading.
* @throws BadFormatException if the data was not in the expected format.
*/
public static List<WordListMetadata> parseMetadata(final InputStreamReader input) throws IOException, BadFormatException {
JsonReader reader = new JsonReader(input);
final ArrayList<WordListMetadata> readInfo = new ArrayList<>();
reader.beginArray();
while (reader.hasNext()) {
final WordListMetadata thisMetadata = parseOneWordList(reader);
if (!TextUtils.isEmpty(thisMetadata.mLocale))
readInfo.add(thisMetadata);
}
return Collections.unmodifiableList(readInfo);
}
use of android.util.JsonReader in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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);
}
Aggregations