import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static HashMap
<String, String
> parseEasyJson
(String json
) { final String regex
= "([^{}: ]*?):(\\{.*?\\}|\".*?\"|[^:{}\" ]*)"; json = json.replaceAll("\n", "");
Matcher m = Pattern.compile(regex).matcher(json);
HashMap
<String, String
> map
= new HashMap
<>(); while (m.find())
map.put(m.group(1), m.group(2));
return map;
}
public static void main
(String[] args
) { String json
= "{\"updated_at\":\"2013-05-24T11:00:26Z\"\n" + "\"created_at\":\"2011-06-28T07:50:25Z\"\n"
+ "\"status\":\"HD [XBOX] Call of Duty Black Ops 2 OPEN LOBBY\"\n"
+ "\"url\":\"http://w...content-available-to-author-only...h.tv/zetaspartan21\"\n"
+ "\"_id\":23170407\n"
+ "\"game\":\"Call of Duty: Black Ops II\"\n"
+ "\"logo\":\"http://s...content-available-to-author-only...w.net/jtv_user_pictures/zetaspartan21-profile_image-121d2cb317e8a91c-300x300.jpeg\"\n"
+ "\"banner\":\"http://s...content-available-to-author-only...w.net/jtv_user_pictures/zetaspartan21-channel_header_image-7c894f59f77ae0c1-640x125.png\"\n"
+ "\"_links\":{\"subscriptions\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/subscriptions\"\n"
+ "\"editors\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/editors\"\n"
+ "\"commercial\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/commercial\"\n"
+ "\"teams\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/teams\"\n"
+ "\"features\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/features\"\n"
+ "\"videos\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/videos\"\n"
+ "\"self\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21\"\n"
+ "\"follows\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/follows\"\n"
+ "\"chat\":\"https://a...content-available-to-author-only...h.tv/kraken/chat/zetaspartan21\"\n"
+ "\"stream_key\":\"https://a...content-available-to-author-only...h.tv/kraken/channels/zetaspartan21/stream_key\"}\n"
+ "\"name\":\"zetaspartan21\"\n"
+ "\"delay\":0\n"
+ "\"display_name\":\"ZetaSpartan21\"\n"
+ "\"video_banner\":\"http://s...content-available-to-author-only...w.net/jtv_user_pictures/zetaspartan21-channel_offline_image-b20322d22543539a-640x360.jpeg\"\n"
+ "\"background\":\"http://s...content-available-to-author-only...w.net/jtv_user_pictures/zetaspartan21-channel_background_image-587bde3d4f90b293.jpeg\"\n"
+ "\"mature\":true}\n";
HashMap
<String, String
> map
= parseEasyJson
(json
); Set
<Entry
<String, String
>> entrySet
= map.
entrySet(); for (Iterator
<Entry
<String, String
>> iterator
= entrySet.
iterator(); iterator
.hasNext();) {
Entry
<String, String
> entry
= (Entry
<String, String
>) iterator
.next();
System.
out.
printf("%-15s:%s%n", entry.
getKey(), entry.
getValue()); }
}
}