I read this article https://www.androidhive.info/2012/01/android-json-parsing-tutorial/ and in this article
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url);
Log.e(TAG, "Response from url: " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
JSONArray contacts = jsonObj.getJSONArray("contacts");
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
String id = c.getString("id");
String name = c.getString("name");
String email = c.getString("email");
String address = c.getString("address");
String gender = c.getString("gender");
// Phone node is JSON Object
JSONObject phone = c.getJSONObject("phone");
String mobile = phone.getString("mobile");
String home = phone.getString("home");
String office = phone.getString("office");
// tmp hash map for single contact
HashMap<String, String> contact = new HashMap<>();
// adding each child node to HashMap key => value
contact.put("id", id);
contact.put("name", name);
contact.put("email", email);
contact.put("mobile", mobile);
// adding contact to contact list
contactList.add(contact);
}
} catch (final JSONException e) {
Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Json parsing error: " + e.getMessage(),
Toast.LENGTH_LONG)
.show();
}
});
}
} else {
Log.e(TAG, "Couldn't get json from server.");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Couldn't get json from server. Check LogCat for possible errors!",
Toast.LENGTH_LONG)
.show();
}
});
}
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, contactList,
R.layout.list_item, new String[]{"name", "email",
"mobile"}, new int[]{R.id.name,
R.id.email, R.id.mobile});
lv.setAdapter(adapter);
}
He/she has retrieved all the values before inflating it to the listview.
I am new to JSon.I tried to retrieve only names but it is not running. So, is it necessary to retrieve all the value before using any of it.
Thank you
The simple answer is: it depends.
When you are the one defining what comes in your JSON data, then you make sure to design it in a "minimalistic" way: you only want to include information that has value for you (or your users). Meaning: in such a world, you only transport the data that you want to display. Then, most likely, your backend code will want to access all data in your JSON strings. Because you designed all these JSON objects to hold only relevant information.
But very often, your code just consumes something. You don't own/define the JSON structure, you just know "there should be fields X, Y, Z in there, which my code will use". Then, obviously, you only extract X, Y, Z. And you leave other data in that JSON alone. There is no point in touching and processing information that isn't relevant for your use case.
In other words: in the real world, you don't do things because you can. You do things, because doing so results in value to you respectively to users of your product.
Related
Hi i am trying to get the json response which has attribute with jsonarray
like (ex: {A:one,B:[{a:one,b:two},{a:two,b:one}]}) i have trying to get
the a:one and b:two values only. But my logcat says error:
RecyclerView: No adapter attached; skipping layout
Json parsing error: Value custom_attributes of type java.lang.String cannot be converted to JSONArray
i want to get this values in textview for my product detail view...
My Coding is :
private class GetProductDetails extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
dialog_pro = new ProgressDialog(Product_Detail_Activity.this);
dialog_pro.setMessage("Please wait...");
dialog_pro.setCancelable(false);
dialog_pro.show();
}
#Override
protected Void doInBackground(Void... arg0) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(BaseURL);
//Log.e(TAG, "Response from url: " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
name = jsonObj.getString("name");
JSONArray items = new JSONArray("custom_attributes");
for (int i = 0; i < items.length(); i++) {
JSONObject c = items.getJSONObject(i);
String atrr = c.getString("attribute_code");
if(atrr.equalsIgnoreCase("short_description")) {
des = c.getString("value");
}
}
}catch (final JSONException e) {
Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Json parsing error: " + e.getMessage(),
Toast.LENGTH_LONG)
.show();
// pro_name.setText("Json error:" + e.getMessage());
}
});
}
} else {
//Log.e(TAG, "Couldn't get json from server.");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Couldn't get json from server. Check LogCat for possible errors!",
Toast.LENGTH_LONG)
.show();
}
});
// AppController.getPermission().addToRequestQueue(jsonObj);
}
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
/**
* Updating parsed JSON data into ListView
* */
if (dialog_pro.isShowing())
dialog_pro.dismiss();
pro_name.setText(name);
short_desc.setText(des);
}
}
Being based on your JSON
try {
JSONObject responseObject = new JSONObject(response);
String A= responseObject.getString("A");
JSONArray bArray= responseObject.getJSONArray("B");
for(int i=0;i<bArray.length();i++){
JSONObject innerObject=bArray.getJSONObject(i);
String a= innerObject.getString("a");
String b= innerObject.getString("b");
}
} catch (Exception e) {
e.printStackTrace();
}
In your code you have JSONArray items = new JSONArray("custom_attributes"); should be changed. You should get your custom_attributes array from the jsonObj object using object.getJSONArray().
For your first problem-RecyclerView: No adapter attached; skipping layout->
Just set an empty adapter first, update it as soon as you have the data (this is what works for me)
For your second problem-Json parsing error: Value custom_attributes of type java.lang.String cannot be converted to JSONArray->
The e.g json that you have posted "{A:one,B:[{a:one,b:two},{a:two,b:one}]}"
it is not in valid json format
This question already has answers here:
How can i check whether an android device is connected to the web?
(4 answers)
Closed 5 years ago.
Android AsyncTask processing and found no internet connection system give warning "user please connect internet". How can I do this in my code?
Another problem is when internet not connected its show loading but I don't go back page. How to solve this problem?
I don't understand how to do this inside this code.
public class data extends AppCompatActivity {
private String TAG = MainActivity.class.getSimpleName();
private ProgressDialog pDialog;
private ListView lv;
// URL to get contacts JSON
private static String url = "http://orangehostbd.com/app/bpl2/index.php";
ArrayList<HashMap<String, String>> contactList;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data);
contactList = new ArrayList<>();
lv = (ListView) findViewById(R.id.list);
new GetContacts().execute();
}
/**
* Async task class to get json by making HTTP call
*/
private class GetContacts extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(data.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
HttpHandler sh = new HttpHandler();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url);
Log.e(TAG, "Response from url: " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
JSONArray contacts = jsonObj.getJSONArray("contacts");
// looping through All Contacts
for (int i = 0; i < contacts.length(); i++) {
JSONObject c = contacts.getJSONObject(i);
String id = c.getString("id");
String name = c.getString("name");
String email = c.getString("email");
String address = c.getString("address");
String gender = c.getString("gender");
// Phone node is JSON Object
JSONObject phone = c.getJSONObject("phone");
String mobile = phone.getString("mobile");
String home = phone.getString("home");
String office = phone.getString("office");
// tmp hash map for single contact
HashMap<String, String> contact = new HashMap<>();
// adding each child node to HashMap key => value
contact.put("id", id);
contact.put("name", name);
contact.put("email", email);
contact.put("mobile", mobile);
// adding contact to contact list
contactList.add(contact);
}
} catch (final JSONException e) {
Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Json parsing error: " + e.getMessage(),
Toast.LENGTH_LONG)
.show();
}
});
}
} else {
Log.e(TAG, "Couldn't get json from server.");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Couldn't get json from server. Check LogCat for possible errors!",
Toast.LENGTH_LONG)
.show();
}
});
}
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
data.this, contactList,
R.layout.list_item, new String[]{"name", "email",
"mobile"}, new int[]{R.id.name,
R.id.email, R.id.mobile});
lv.setAdapter(adapter);
}
}
}
Create a Helper class.
Inside this class, create a method to check internet connection.
public static boolean isNetworkConnected(Context context) {
final ConnectivityManager connectivityManager = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
return connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnected();
}
Inside your activity class, use above isNetworkConnected() method in doInBackground.
if (Helper.isNetworkConnected(this)) {
// do your stuff
} else{
Toast.makeText(YourActivity.this, "Your internet connection is lost.", Toast.LENGTH_SHORT).show();
}
Use this permission in Manifest file.
<uses-permission android:name="android.permission.INTERNET" />
If the question is "how to display warning inside doInBackground" because you are not allowed to access the gui inside doInBackground technically you can use the progress indicator of asynctask to transfer a message to the gui.
However i would recommond a differen aproach: either
check for problems before starting the async task
or let the async task stop and return with an error as described by #Muthukrishnan Rajendran
i'm using JSON for requesting text and put it in a list view with custom adapter, here is my code so far..
private class getMovies extends AsyncTask<Void, Void, Void> {
#Override
protected void onPreExecute() {
super.onPreExecute();
// Showing progress dialog
pDialog = new ProgressDialog(alrehabfilms.this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
pDialog.show();
}
#Override
protected Void doInBackground(Void... arg0) {
http sh = new http();
// Making a request to url and getting response
String jsonStr = sh.makeServiceCall(url);
// Log.e(TAG, "Response from url: " + jsonStr);
if (jsonStr != null) {
try {
JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
JSONArray moviesp90 = jsonObj.getJSONArray("moviesalrehab");
// looping through All Contacts
for (int i = 0; i < moviesp90.length(); i++) {
JSONObject c = moviesp90.getJSONObject(i);
String id = c.getString("id");
String name = c.getString("name");
String actors = c.getString("actors");
String tandp = c.getString("prizeandtime");
String img = c.getString("img"); //here is for the image
// Phone node is JSON Object
JSONObject pref = c.getJSONObject("pref");
String imrating = pref.getString("imrating");
String genre = pref.getString("genre");
String guide = pref.getString("guide");
String director = pref.getString("director");
// tmp hash map for single contact
HashMap<String, String> movie = new HashMap<>();
// adding each child node to HashMap key => value
movie.put("id", id);
movie.put("name", name);
movie.put("actors", actors);
movie.put("prizeandtime", tandp);
if(img != null && !img.equalsIgnoreCase("")) Picasso.with(alrehabfilms.this).load(img).into(imggg); //here idk how to put like movie.put("img", Picasso code)
movie.put("imrating", imrating);
movie.put("genre", genre);
movie.put("guide", guide);
movie.put("director", director);
// adding contact to contact list
alrehabmovieList.add(movie);
}
} catch (final JSONException e) {
// Log.e(TAG, "Json parsing error: " + e.getMessage());
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"An error happened, please try again!",
Toast.LENGTH_LONG)
.show();
}
});
}
} else {
// Log.e(TAG, "Couldn't get json from server.");
runOnUiThread(new Runnable() {
#Override
public void run() {
Toast.makeText(getApplicationContext(),
"Failed to retrieve data, please check your internet connection",
Toast.LENGTH_LONG)
.show();
AlertDialog.Builder adb = new AlertDialog.Builder(alrehabfilms.this);
adb.setTitle("No internet connection");
adb.setMessage("Would you like to try to gather data again?");
adb.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
new getMovies().execute();
} });
adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
} });
adb.show();
}
});
}
return null;
}
#Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
if (pDialog.isShowing())
pDialog.dismiss();
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
alrehabfilms.this, alrehabmovieList,
R.layout.imgtest, new String[]{"name", "actors",
"prizeandtime", "img", "imrating", "genre","guide", "director"}, new int[]{R.id.movieName,
R.id.movieActors, R.id.moviePrizeAndTime, R.id.imggg//imageeview, R.id.movieRating, R.id.movieGenre,R.id.pGuid, R.id.dir});
lv.setAdapter(adapter);
}
}
}
As you see here, i put this line for the image
String img = c.getString("img"); //here is for the image
My problem here is how to put it in that way
movie.put("img", THECODEIWANT);
instead of this,
if(img != null && !img.equalsIgnoreCase(""))
Picasso.with(alrehabfilms.this).load(img).into(imggg);
thanks in advance
Why do you want to directly put the image in the array?
You can do that but it will block your app while it gets real Bitmap image data from Picasso.
That is why we are using Picasso to asynchronously load image in the background thread.
I have been struggling to understand the logic of the Android JSON Parsing with volley libraries.I am trying to get JSON Array and parse with Volley Libraries.I understand how JSON data is extracted from PHP file but I have big problems. makeJsonArrayRequest() function runs correctly and parse JSON Array from get_data.php file and add users ArrayList from User class in each iteration.I called this function in onCreate and userLogin function individually.Size of users ArrayList equals to 0 when I call makeJsonArrayRequest() function in onCreate method .However,Size of users ArrayList equals to nonzero number when I call makeJsonArrayRequest() function in userLogin method(This method called when clicked on Login Button).This is my problem.Why makeJsonArrayRequest() doesn't run on Create() method ?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ET_NAME = (EditText) findViewById(R.id.user_name);
ET_PASS = (EditText) findViewById(R.id.user_pass);
pDialog = new ProgressDialog(this);
pDialog.setMessage("Please wait...");
pDialog.setCancelable(false);
makeJsonArrayRequest();
Toast.makeText(getApplicationContext(),"Size:" + users.size(),Toast.LENGTH_LONG).show();
}
public void userLogin(View view) {
login_name = ET_NAME.getText().toString();
login_pass = ET_PASS.getText().toString();
String method = "login";
String status = "1";
BackgroundTask backgroundTask = new BackgroundTask(this);
backgroundTask.execute(method, login_name, login_pass, status);
Intent i = new Intent(this,MapsActivity.class);
i.putExtra("username",login_name);
i.putExtra("userpass", login_pass);
makeJsonArrayRequest();
startActivity(i);
Toast.makeText(getApplicationContext(),"Size:" + users.size(),Toast.LENGTH_LONG).show();
}
private void makeJsonArrayRequest() {
showpDialog();
JsonArrayRequest req = new JsonArrayRequest(JSON_URL,
new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
try {
// Parsing json array response
// loop through each json object
jsonResponse ="";
for (int i = 0; i < response.length(); i++) {
JSONObject person = (JSONObject) response.get(i);
String name = person.getString("name");
String username = person.getString("username");
String password = person.getString("password");
double latitude = Double.parseDouble(person.getString("latitude"));
double longitude = Double.parseDouble(person.getString("longitude"));
String status = person.getString("status");
User user = new User(name,username,password,latitude,longitude,status);
users.add(user);
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),
"Error: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
hidepDialog();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_SHORT).show();
hidepDialog();
}
});
// Adding request to request queue
AppController.getInstance().addToRequestQueue(req);
}
If what you're saying is :
I run the request in onCreate() and check - it's empty.
and then:
I run it again LATER, and Check - it's full.
then have you considered the request latency? it takes time (albeit - not much time) for the request to return, you might be checking before it does
EDIT:
Run what you want inside the onResponse(), that's only called when the request returns.
Hope this helps.
Need help on android =( been stuck on this for ages! My codes are as shown.
public class AllUsersActivity extends ListActivity {
// Progress Dialog
private ProgressDialog pDialog;
// Creating JSON Parser object
JSONParser jParser = new JSONParser();
ArrayList<HashMap<String, String>> usersList;
// url to get all users list
private static String url_all_users = "http://10.0.2.2/android_connect/get_all_users.php";
// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_USERS = "users";
private static final String TAG_UID = "UserID";
private static final String TAG_FIRSTNAME = "FirstName";
// users JSONArray
JSONArray users = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_users);
// Hashmap for ListView
usersList = new ArrayList<HashMap<String, String>>();
// Loading users in Background Thread
new LoadAllusers().execute();
// Get listview
ListView lv = getListView();
// on seleting single product
// launching Edit Product Screen
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// getting values from selected ListItem
String uid = ((TextView) view.findViewById(R.id.uid)).getText()
.toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(),
UserDetailsActivity.class);
// sending uid to next activity
in.putExtra(TAG_UID, uid);
// starting new activity and expecting some response back
startActivityForResult(in, 100);
}
});
}
// Response from Edit Product Activity
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// if result code 100
if (resultCode == 100) {
// if result code 100 is received
// means user edited/deleted product
// reload this screen again
Intent intent = getIntent();
finish();
startActivity(intent);
}
}
/**
* Background Async Task to Load all product by making HTTP Request
* */
class LoadAllusers extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
#Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(AllUsersActivity.this);
pDialog.setMessage("Loading users. Please wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
}
/**
* getting All users from url
* */
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_all_users, "GET", params);
// Check your log cat for JSON reponse
Log.d("All users: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// users found
// Getting Array of users
users = json.getJSONArray(TAG_USERS);
// looping through All users
for (int i = 0; i < users.length(); i++) {
JSONObject c = users.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_UID);
String name = c.getString(TAG_FIRSTNAME);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_UID, id);
map.put(TAG_FIRSTNAME, name);
// adding HashList to ArrayList
usersList.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all users
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
AllUsersActivity.this, usersList,
R.layout.list_item, new String[] { TAG_UID,
TAG_FIRSTNAME},
new int[] { R.id.uid, R.id.name });
// updating listview
setListAdapter(adapter);
}
});
}
}
Can anyone please help me! The error i've been getting is Error Parsing Data Org.json.JSONException: Value cannot be converted to JSONObject
Heres the JSON string
Array{"Users":[{"UserID":"1","FirstName":"lalawee","Email":"12345","Password":null},{"UserID":"2","FirstName":"shadowblade721","Email":"12345","Password":null},{"UserID":"3","FirstName":"dingdang","Email":"12345","Password":null},{"UserID":"4","FirstName":"solidsnake0328","Email":"12345","Password":null}],"success":1}
Is the error lying in the JSON parser class?
EDIT: here the code for the php script that outputs the array above. can anyone tell me what's wrong with the php script that outputs the word array before the json string? Sorry for the trouble. I'm new to coding. Been following online tutorials but stuck on this for a few days now.
<?php
/*
* Following code will list all the Users
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get all Users from Users table
$result = mysql_query("SELECT * FROM Users") or die(mysql_error());
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// Users node
$response["Users"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$user[] = array();
$user["UserID"] = $row["UserID"];
$user["FirstName"] = $row["FirstName"];
$user["Email"] = $row["Email"];
$user["Password"] = $row["Password"];
// push single User into final response array
array_push($response["Users"], $user);
}
// success
$response["success"] = 1;
echo $response;
// echoing JSON response
echo json_encode($response);
}
else {
// no Users found
$response["success"] = 0;
$response["message"] = "No Users found";
// echo no users JSON
echo json_encode($response);
}
?>
Use GSON library instead, it is official Google and works like a charm. No HashMaps etc, immediate objects.
Take a look at it here.
As the error suggests, your JSON string does not represent a valid JSON object.
Try like this(without Array in the beginning):
{"Users":[{"UserID":"1","FirstName":"lalawee","Email":"12345","Password":null},{"UserID":"2","FirstName":"shadowblade721","Email":"12345","Password":null},{"UserID":"3","FirstName":"dingdang","Email":"12345","Password":null},{"UserID":"4","FirstName":"solidsnake0328","Email":"12345","Password":null}],"success":1}Array{"Users":[{"UserID":"1","FirstName":"lalawee","Email":"12345","Password":null},{"UserID":"2","FirstName":"shadowblade721","Email":"12345","Password":null},{"UserID":"3","FirstName":"dingdang","Email":"12345","Password":null},{"UserID":"4","FirstName":"solidsnake0328","Email":"12345","Password":null}],"success":1}
You can check the validity of your JSON String here: http://jsonlint.com/