package com.mycompany.json;
import android.os.;
import android.support.v7.app.AppCompatActivity;
import android.widget.;
import org.json.JSONObject;
import org.json.JSONException;
public class MainActivity extends AppCompatActivity
{ String my_Json="{“employee”:{“name”:“Joseph”,“salary”:3000}}";
String name,salary;
TextView employeename,employeesalary;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
employeename=(TextView)findViewById(R.id.textv_name);
employeesalary=(TextView)findViewById(R.id.textv_salary);
try{
JSONObject obj=new JSONObject(my_Json);
JSONObject employee=obj.getJSONObject("employee");
name=employee.getString("name");
salary=employee.getString("salary");
employeename.setText("Name:" +name);
employeesalary.setText("Salary:"+salary);
}catch(JSONException e){
e.printStackTrace();
}
}
}