Android JsonParser - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android JsonParser class.

This code example shows how to use the following methods:parse
            } catch (IOException e) {
                e.printStackTrace();
            } 
        } 
 
        final JsonParser parser = new JsonParser();
        try { 
            jsonObject = (JsonObject) parser.parse(result);
        } catch (ClassCastException ignore) {
            jsonObject = new JsonObject();
        } 
    } 
 
    public ArrayList<Long> getMeasurements() {
        final JsonArray jsonArray = jsonObject.getAsJsonArray("results");
        final ArrayList<Long> medianList = new ArrayList<Long>();
        if (jsonArray == null) return medianList;
 
        for (int scenario = 0; scenario < jsonArray.size(); scenario++) {
            final JsonArray measurementArray = jsonArray.get(scenario).getAsJsonObject().getAsJsonArray("measurements");
8
CodeRank
This code example shows how to use the following methods:
		} 
	} 
 
	private DefaultHttpClient httpclient = new DefaultHttpClient();
	private Gson gson = new Gson();
	private JsonParser parser = new JsonParser(); 
	private final String[] platforms = { "android", "ios", "blackberry",
			"symbian", "webos" }; 
	private final Map<String, String> extensionMap = new HashMapExtension();
 
	public PhonegapAPIHelper() { 
		super(); 
	} 
 
	public void getBuildError(int id, String platform) throws NamingException,
			IllegalStateException, IOException { 
		if (!Arrays.asList(platforms).contains(platform)) {
			throw new NamingException("unsupported platfom :" + platform);
		} 
 
7
CodeRank
This code example shows how to use the following methods:parse
	public IRCCloudJSONObject() { 
		o = new JsonObject();
	} 
	 
	public IRCCloudJSONObject(String message) {
		JsonParser parser = new JsonParser();
		o = parser.parse(message).getAsJsonObject();
	} 
	 
	public IRCCloudJSONObject(JSONObject object) {
		JsonParser parser = new JsonParser();
		o = parser.parse(object.toString()).getAsJsonObject();
	} 
	 
	public IRCCloudJSONObject(JsonObject object) {
		o = object;
	} 
	 
	public int cid() { 
		if(cid == -1 && o.has("cid"))
8
CodeRank
This code example shows how to use the following methods:parse
 
	public static JsonElement parse(Reader reader) {
		if (reader == null) {
			return null; 
		} 
		JsonParser parser = new JsonParser();
		JsonElement ret = parser.parse(reader);
		return ret;
	} 
 
	public static JsonElement parse(String json) {
		if (json == null) {
			return null; 
		} 
		JsonParser parser = new JsonParser();
		JsonElement ret = parser.parse(json);
		return ret;
	} 
 
	public static void format(JsonElement element, Writer writer) {
6
CodeRank
This code example shows how to use the following methods:parse
	public static String NOTEPAD_PACKAGE_NAME = "org.openintents.notepad";
	public static String SHOPPINGLIST_PACKAGE_NAME = "org.openintents.shoppinglist";
	 
	public static String appendJSON(String jsonString, String name, Long data)
	{ 
		JsonParser parser = new JsonParser();
		 
		JsonObject object = parser.parse(jsonString).getAsJsonObject();
		 
		object.addProperty(name, data);
		 
		return object.toString();
	} 
	 
	public static String appendJSON(String jsonString, String name, String data)
	{ 
		JsonParser parser = new JsonParser();
		 
		JsonObject object = parser.parse(jsonString).getAsJsonObject();
		 
7
CodeRank
This code example shows how to use the following methods:parse
			DefaultHttpClient httpclient = new DefaultHttpClient();
			HttpGet request = new HttpGet(query);
			request.setHeader("Accept", "application/json");
			request.setHeader("Accept-Encoding", "gzip");
			HttpResponse response = httpclient.execute(request);
			JsonParser parser = new JsonParser();
			return (JsonObject) parser.parse(response.toString());
		} catch (Exception e) {
			return null; 
		} 
	} 
 
	/** 
	 * @param args 
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 * @throws InterruptedException 
	 */ 
	public static void main(String[] args) throws ClientProtocolException, IOException, InterruptedException {
		String URL;
7
CodeRank
This code example shows how to use the following methods:
	private Date minDate = new Date(longDate);
 
	@Before 
	public void setup() { 
		reportSerializer = new ReportJsonFactory(new JsonParser());
		factory = new ReportJsonFactory(new JsonParser());
 
		report = getReport();
 
	} 
 
	@Test 
	public void serializerTest() { 
 
	} 
 
	@Test 
	public void deSerializerTest() { 
		assertNull(reportSerializer.deserialize(""));
	} 
6
CodeRank
This code example shows how to use the following methods:parse
        JsonElement jsonElement = null;
 
        if (isNull(data)) return null;
 
        try {			 
            JsonParser parser = new JsonParser();
            jsonElement = parser.parse(data);
        } catch (JsonParseException e) {
            e.printStackTrace();
            throw new JSONMatjiException(); 
        } 
        if (!isObject(jsonElement)){
            throw new JSONMatjiException(); 
        } 
 
        jsonObject = jsonElement.getAsJsonObject();
 
        return getMatjiData(jsonObject);
    } 
 
7
CodeRank
This code example shows how to use the following methods:parse
    public void setup() throws IOException { 
        File jsonFile = new File("json/bloginfo.json");
        FileReader fr;
        fr = new FileReader(jsonFile);
        BufferedReader br = new BufferedReader(fr);
        JsonParser parser = new JsonParser();
        JsonElement jelement = parser.parse(br);
        response =  new Response(jelement);
        br.close();
        fr.close();
         
    } 
    @Test 
    public void blog() { 
        Blog blog = response.getBlog();
        assertEquals("David's Log", blog.getTitle());
        assertEquals("david", blog.getName());
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:
 * Object representing a status. 
 */ 
public class Status  
{ 
  private static final HtmlStatusExtractor extractor = new HtmlStatusExtractor();
  private static final JsonParser parser = new JsonParser();
 
  private long id;
  private String screenname;
  private String createdAt;
  private String text;
  private int httpStatusCode;
  private JsonObject jsonObject;
  private String jsonString;
 
  protected Status() {} 
   
  public long getId() { 
    return id;
  } 
6
CodeRank

Related Android JsonParser Questions & Answers:

See Code Examples for Android JsonParser Methods: