0
{
  "application_num" : 185,
  "age" : 35,
  "mobile_num" : "9943847180",
  "active" : null,
  "photo" : null,
  "bytes" : null,
  "creator" : null,
  "modifier" : null,
  "modifiedby" : null,
  "updatedby" : null,
  "cus_first_name" : "firstname",
  "cus_last_name" : "lastname",
  "sex" : "Male",
  "profession" : "profession",
  "designation" : "designation",
  "work_place_address" : "workkkkkkkkkk",
  "phone_number" : "044222222222",
  "resi_address" : "resssssssssssssi",
  "membership_type" : "Silver",
  "debitbal" : "100022",
  "dueamt" : "1002",
  "renewaldate" : "2013-06-13",
  "photoinputstream" : null
}

this is my json string.I stored in String myjsonString, Approbvall_BE is my class. This is my code.

Gson gson=new Gson(); 
//convert the json string back to object
Approval_BE app_be = gson.fromJson(myjsonString, Approval_BE.class);
System.out.println("print"+app_be.cus_first_name);

after this line even s.o.p itself not working. Can anyone help me?.

Approval_BE app_be = gson.fromJson(myjsonString, Approval_BE.class);
1

3 Answers 3

1

Use jsonschema2pojo to generate model for your JSON, and use the same code to deserilize it to java object

Sign up to request clarification or add additional context in comments.

Comments

0
    String str = "Your json string";

JSONObject json = new JSONObject(str);

1 Comment

i want to convert ah java object .. not json
0

import org.codehaus.jackson.map.ObjectMapper;

pass json in readvalue method

User user = new ObjectMapper().readValue(json, User.class);

this will conver json to java

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.