Parsing a List [closed]











up vote
-1
down vote

favorite












I have a List Which contains json values as String. When I try to iterate this List it gives me the whole json as single element but I want to split the json values.



String val = jdbcTemplate.queryForObject("SELECT DETAILEDINVINFO FROM VTRTINVOICE where invnno=?" , new Object{invoiceVO.getInvoiceNo()}, String.class);
List<Object> result = (List<Object>) new Gson().fromJson(val, Object.class);
Where result= "detailedInvInfo":[
{
"name":"jerry 053E",
"date":"19-11-2017",
"number":"AMPU246890",
"broker":"broker black",
}
]


I need to parse the list so that i get values for each parameter like name, date etc.



Thanks in advance.










share|improve this question















closed as too broad by talex, Basil Bourque, chŝdk, Unheilig, EdChum Nov 22 at 9:31


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    This link seems like it might be related.
    – Moishe Lipsker
    Nov 22 at 5:41















up vote
-1
down vote

favorite












I have a List Which contains json values as String. When I try to iterate this List it gives me the whole json as single element but I want to split the json values.



String val = jdbcTemplate.queryForObject("SELECT DETAILEDINVINFO FROM VTRTINVOICE where invnno=?" , new Object{invoiceVO.getInvoiceNo()}, String.class);
List<Object> result = (List<Object>) new Gson().fromJson(val, Object.class);
Where result= "detailedInvInfo":[
{
"name":"jerry 053E",
"date":"19-11-2017",
"number":"AMPU246890",
"broker":"broker black",
}
]


I need to parse the list so that i get values for each parameter like name, date etc.



Thanks in advance.










share|improve this question















closed as too broad by talex, Basil Bourque, chŝdk, Unheilig, EdChum Nov 22 at 9:31


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.











  • 1




    This link seems like it might be related.
    – Moishe Lipsker
    Nov 22 at 5:41













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a List Which contains json values as String. When I try to iterate this List it gives me the whole json as single element but I want to split the json values.



String val = jdbcTemplate.queryForObject("SELECT DETAILEDINVINFO FROM VTRTINVOICE where invnno=?" , new Object{invoiceVO.getInvoiceNo()}, String.class);
List<Object> result = (List<Object>) new Gson().fromJson(val, Object.class);
Where result= "detailedInvInfo":[
{
"name":"jerry 053E",
"date":"19-11-2017",
"number":"AMPU246890",
"broker":"broker black",
}
]


I need to parse the list so that i get values for each parameter like name, date etc.



Thanks in advance.










share|improve this question















I have a List Which contains json values as String. When I try to iterate this List it gives me the whole json as single element but I want to split the json values.



String val = jdbcTemplate.queryForObject("SELECT DETAILEDINVINFO FROM VTRTINVOICE where invnno=?" , new Object{invoiceVO.getInvoiceNo()}, String.class);
List<Object> result = (List<Object>) new Gson().fromJson(val, Object.class);
Where result= "detailedInvInfo":[
{
"name":"jerry 053E",
"date":"19-11-2017",
"number":"AMPU246890",
"broker":"broker black",
}
]


I need to parse the list so that i get values for each parameter like name, date etc.



Thanks in advance.







java json database arraylist






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 8:15









Bishal Gautam

406416




406416










asked Nov 22 at 5:38









vaijayanthi Sriram

4




4




closed as too broad by talex, Basil Bourque, chŝdk, Unheilig, EdChum Nov 22 at 9:31


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by talex, Basil Bourque, chŝdk, Unheilig, EdChum Nov 22 at 9:31


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    This link seems like it might be related.
    – Moishe Lipsker
    Nov 22 at 5:41














  • 1




    This link seems like it might be related.
    – Moishe Lipsker
    Nov 22 at 5:41








1




1




This link seems like it might be related.
– Moishe Lipsker
Nov 22 at 5:41




This link seems like it might be related.
– Moishe Lipsker
Nov 22 at 5:41












1 Answer
1






active

oldest

votes

















up vote
-1
down vote













Please try something like below code:



for(Object o:result){
JSONObject jsonObject = new JSONObject(o);
String name = (String) jsonObject.get("name");
String date = (String) jsonObject.get("date");
}





share|improve this answer























  • I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
    – vaijayanthi Sriram
    Nov 22 at 6:27


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
-1
down vote













Please try something like below code:



for(Object o:result){
JSONObject jsonObject = new JSONObject(o);
String name = (String) jsonObject.get("name");
String date = (String) jsonObject.get("date");
}





share|improve this answer























  • I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
    – vaijayanthi Sriram
    Nov 22 at 6:27















up vote
-1
down vote













Please try something like below code:



for(Object o:result){
JSONObject jsonObject = new JSONObject(o);
String name = (String) jsonObject.get("name");
String date = (String) jsonObject.get("date");
}





share|improve this answer























  • I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
    – vaijayanthi Sriram
    Nov 22 at 6:27













up vote
-1
down vote










up vote
-1
down vote









Please try something like below code:



for(Object o:result){
JSONObject jsonObject = new JSONObject(o);
String name = (String) jsonObject.get("name");
String date = (String) jsonObject.get("date");
}





share|improve this answer














Please try something like below code:



for(Object o:result){
JSONObject jsonObject = new JSONObject(o);
String name = (String) jsonObject.get("name");
String date = (String) jsonObject.get("date");
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 at 6:38









talex

8,2871545




8,2871545










answered Nov 22 at 6:00









Priyadeep Datta

172




172












  • I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
    – vaijayanthi Sriram
    Nov 22 at 6:27


















  • I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
    – vaijayanthi Sriram
    Nov 22 at 6:27
















I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
– vaijayanthi Sriram
Nov 22 at 6:27




I am getting an exception saying: org.json.JSONException: JSONObject["name"] not found.
– vaijayanthi Sriram
Nov 22 at 6:27



Popular posts from this blog

Catalogne

Violoncelliste

Héron pourpré