I have got GSON as a JSON parser in Java, but the keys aren\'t always the same.
For example. I have the following JSON:
{ \"The Object I already
Since Java 8 you can use Streams as better looking alternative:
String str = "{\"key1\":\"val1\", \"key2\":\"val2\"}";
JsonParser parser = new JsonParser();
JsonObject jObj = (JsonObject) parser.parse(str);
List keys = jObj.entrySet()
.stream()
.map(i -> i.getKey())
.collect(Collectors.toCollection(ArrayList::new));
keys.forEach(System.out::println);