Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.json.JSONObject;

public class Main {
    public static String commandExecutionStatusMessage(String jsonString) {
        try {
            JSONObject json = new JSONObject(jsonString);
            String condition = json.getString("condition");
            String message = json.getString("message");

            if (message == "null") {
                if (condition == "true")
                    return "Successful";
                else
                    return "Error";
            } else {
                return message;
            }
        } catch (Exception e) {
            return e.toString();
        }
    }
}