json map to string failure in java -


In Java, I am trying to convert a map into a json string. Using the code given below throws IOException

  Send a private zeroSessions (map & lt; string, string & gt; feedback map) to IOException {PrintStream ps = new PrintStream (clientSocket.getOutputStream ()); JSONObject json = New JSONObject (responseMap); Ps.println (json.toString ()); }   

Variable

  JS value result {"empty": wrong} added valid key values ​​to the map   

There are such values ​​in the map

  responseMap.put ("response", "right"); ResponseMap.put ("versionname", "Dummy"); ResponseMap.put ("versioncode", "Dummy"); ResponseMap.put ("package", "dummy"); ResponseMap.put ("deviceid", "unknown"); ResponseMap.put ("devicename", "dummy"); ResponseMap.put ("Synchronization", blank); ResponseMap.put ("Additional", "");   

The code I am using

Why is it not by any idea?

Map to Jason, Jason to map? I do not have any problem using Gson lib.

Map for Jason String

  GSOnGSN = New GSN Builder (). SetPrettyPrinting () Create (); Maps & lt; String, string & gt; Map = new hashmap & lt; String, string & gt; (); Map.put ("111", "AAAAAAA"); Map.put ("222", "BBBBB"); String Map String = gson.toJson (map); Println (mapString);    

output

  {"222": "BBBBB", "111": "AAAAAA"}   

Jason String Map

  GSON GSN = New GSOnBiller (). Satty Printing () Create (); String mapstrings = "{\" 222 \ ": \" BBBBB \ ", \" 111 \ ": \" AAAAAAA \ "}"; Maps & lt; String, string & gt; Map = gson.fromJson (map string, map.clash); Println (map.get ("111"));   

Output

  AAAAA    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -