-1

I have one map file

 Map<String,Object> personData = procReadData.execute(in);

The data is coming from this is

{CUR_GENERIC=[{PROPOSAL_NUMBER=1, TITLE=test proposal, LEAD_UNIT_NAME=University, FULL_NAME=test, STSTUS_CODE=Pending, DOCUMENT_TAKEN_BY=user1 qa, UPDATE_TIMESTAMP=2015-12-28 00:00:00.0, UPDATE_USER=test}]}

How to get PROPOSAL_NUMBER from that result.

Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42
VSN
  • 41
  • 8
  • @NathanTuggy: problem seems not to be to convert to JSON, but to work with the converted object – P.J.Meisch Dec 30 '15 at 05:14
  • @P.J.Meisch: Unless I'm mistaken, the dupe covers the basics of that as well. – Nathan Tuggy Dec 30 '15 at 05:16
  • @NathanTuggy: the dupe has a lot of good information about different libraries that can be used to convert JSON in better ways than just using a Map. But we don't know if the OP can change the conversion implementation ;-) – P.J.Meisch Dec 30 '15 at 05:20

1 Answers1

1

You should check what type the result of

personData.get("CUR_GENERIC");

is (use a debugger for this if you have no documentation available). It's probably a list or an array of Map<String, Object> depending on what tool was used to convert the JSON data to a Java map. Get the first entry of this list or array and then use get("PROPOSAL_NUMBER") to retrieve the entry you want.

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
  • When use personData.get("CUR_GENERIC"); Result is [{PROPOSAL_NUMBER=1, TITLE=test proposal, LEAD_UNIT_NAME=University, FULL_NAME=test, STSTUS_CODE=Pending, DOCUMENT_TAKEN_BY=user1 qa, UPDATE_TIMESTAMP=2015-12-28 00:00:00.0, UPDATE_USER=test}] But when I use get("PROPOSAL_NUMBER") result is null.Didnot get data – VSN Dec 30 '15 at 05:31
  • what data type has the returned value of `personData.get()`? How do you see what the result is? Could you please add the java code you use to extract the values to your question? – P.J.Meisch Dec 30 '15 at 05:48
  • Iam using spring jdbc template for calling procedureprocReadData = new SimpleJdbcCall(dataSource).withProcedureName("GET_EPAWS_PERSON_DETAILS") .declareParameters(new SqlParameter("AV_USER_NAME", OracleTypes.VARCHAR)); SqlParameterSource in = new MapSqlParameterSource().addValue("AV_USER_NAME", principal.getName()); Map personData = procReadData.execute(in); logger.debug("|__PersonData=="+personData.get("CUR_GENERIC")); With in this I need to get PROPOSAL_NUMBER – VSN Dec 30 '15 at 05:52
  • Result is [{PROPOSAL_NUMBER=1, TITLE=test proposal, LEAD_UNIT_NAME=University, FULL_NAME=test, STSTUS_CODE=Pending, DOCUMENT_TAKEN_BY=user1 qa, UPDATE_TIMESTAMP=2015-12-28 00:00:00.0, UPDATE_USER=test}] With in this I need to get PROPOSAL_NUMBER – VSN Dec 30 '15 at 05:55
  • can you show the output of `logger.debug(personData.get("CUR_GENERIC").getClass().getCanonicalName());`? – P.J.Meisch Dec 30 '15 at 06:16
  • Output is java.util.ArrayList – VSN Dec 30 '15 at 06:59
  • then `((ArrayList)personData.get("CUR_GENERIC“)).get(0).get("PROPOSAL_NUMBER")` should do. With this expression, you cast the result to ArrayList, get the first element of it and then access this element's PROPOSAL_NUMBER entry. I assume, that the ArrayList contains Map entries. – P.J.Meisch Dec 30 '15 at 07:57