Created
March 25, 2015 18:10
-
-
Save IPRIT/34193b6218201bb9d582 to your computer and use it in GitHub Desktop.
Example ResponseParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ru.twosphere.android.misisbooks; | |
import android.util.Log; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
/** | |
* Created by Александр on 31.01.2015. | |
*/ | |
public class MisisBooksDataParser { | |
private String apiResponse; | |
public Edition[] getEditionsFromResponse(String apiResponseJsonStr) | |
throws JSONException { | |
apiResponse = apiResponseJsonStr; | |
final String OWN_RESPONSE = "response"; | |
final String OWN_ITEMS = "items"; | |
JSONObject responseJsonObject = new JSONObject(apiResponseJsonStr); | |
JSONArray editionsArray = responseJsonObject.getJSONObject(OWN_RESPONSE).getJSONArray(OWN_ITEMS); | |
Log.d("MISIS Books parser", String.valueOf(editionsArray.length())); | |
Edition[] mArr = new Edition[editionsArray.length()]; | |
for (int i = 0; i < editionsArray.length(); i++) { | |
mArr[i] = new Edition(editionsArray.getJSONObject(i)); | |
} | |
return mArr; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment