fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String str = "{\"AAA\":xxxxx,\"BB\":xxxx,\"CCC\":\"3 xxx\"}";
  13. str = str.substring(1, str.length() - 1); // removing the {}
  14. String[] entries = str.split(","); // get all the "key":value
  15. for (String entry: entries) {
  16. String[] entryData = entry.split(":"); // get the key and the value
  17. String key = entryData[0];
  18. key = key.substring(1, key.length() - 1); // removing the "" from key
  19. String value = entryData[1];
  20. System.out.println(key + " -> " + value);
  21. }
  22. }
  23. }
Success #stdin #stdout 0.06s 380224KB
stdin
{"AAA":xxxxx,"BB":xxxx,"CCC":"3 xxx"}
stdout
AAA -> xxxxx
BB -> xxxx
CCC -> "3 xxx"