- Open With Google Docs Json Parsing Example Step By Step Step 1 Create A New Project And Name It Jsonparsingexample 1 (134.75 KiB) Viewed 34 times
Open with Google Docs JSON Parsing Example (Step by Step): Step 1: Create a new project and name it JSONParsingExample.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Open with Google Docs JSON Parsing Example (Step by Step): Step 1: Create a new project and name it JSONParsingExample.
Open with Google Docs JSON Parsing Example (Step by Step): Step 1: Create a new project and name it JSONParsingExample. Step 2: Open res -> layout -> activity_main.xml (or) main.xml and add following code: In this step we create two TextView's for displaying employee name and salary. Step 3: Now open app ->java -> package -> MainActivity.java and add the below code. In this step firstly we get the reference of both TextView's then we parse the JSON using JSONObject methods and finally we set the data in Textview's. // get SoNobject from JSON file SONObject obj = new JSONObject(JSON_STRING); 11 fetch JSONObject named employee JSONObject employee = obj.getjsoNobject("employee"); // get employee name and salary name = employee.getString("name"); salary = employee.getString("salary"); // set employee name and salary in TextView's employeeName.setText("Name: "-name); employeeSalary.setText("Salary: "+salary); Tasks: Using JSONArray and JSONObject (separately), parse the JSON data and display on UI. Page 2 1 2 - +