java - How to Extract the currencies json result string -


in java project got currency code , expansion json string result of api call.below json result.

      string jsonstring = {     "aed": "united arab emirates dirham",     "afn": "afghan afghani",     "all": "albanian lek",     "amd": "armenian dram",     "ang": "netherlands antillean guilder",     "aoa": "angolan kwanza",     "ars": "argentine peso",     "aud": "australian dollar",     "awg": "aruban florin",     "azn": "azerbaijani manat",     "bam": "bosnia-herzegovina convertible mark",     "bbd": "barbadian dollar",     "bdt": "bangladeshi taka",     "bgn": "bulgarian lev",     "bhd": "bahraini dinar",     "bif": "burundian franc",     "bmd": "bermudan dollar",     "bnd": "brunei dollar",     "bob": "bolivian boliviano",     "brl": "brazilian real",     "bsd": "bahamian dollar",     "btc": "bitcoin",     "btn": "bhutanese ngultrum",     ......     } 

now how can extract key value pair above json string currency code comes key , expansion comes value, can store list or map.

you can use jackson reading json inputstream/string/byte[]/url/file/reader map<string,string> using below code:

  objectmapper mapper = new objectmapper();// construction @ application level. not every call.   map<string,string> codedescmap = mapper.readvalue(source,mapper.gettypefactory()         .constructmapliketype(map.class,               string.class,string.class)); 

where source can inputstream/string/byte[]/url/file/reader valid json structure.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -