Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created February 18, 2023 18:06
Show Gist options
  • Save jskeet/9500c6e62bdc72953c15332684fb765d to your computer and use it in GitHub Desktop.
Save jskeet/9500c6e62bdc72953c15332684fb765d to your computer and use it in GitHub Desktop.
import org.json.JSONObject;
public class Test {
public static void main(String args[]) {
String json = "{ \"status\": \"failed\", \"message\": \"All fields are required\" }";
JSONObject jsonObject = new JSONObject(json);
String status = jsonObject.getString("status");
String message = jsonObject.getString("message");
System.out.println("status=" + status);
System.out.println("message=" + message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment