String data is json ; yes return true, no return false; - Android File Input Output

Android examples for File Input Output:Json String

Description

String data is json ; yes return true, no return false;

Demo Code


//package com.java2s;

public class Main {
    /**/*from  w w  w.j a va 2 s . c o  m*/
     * String data is json ; yes return true, no return false;
     */
    public static boolean isJson(String json) {
        if (json == null || json.equals("")) {
            return false;
        }
        json = json.trim();
        if ("{".equals(json.substring(0, 1))
                && "}".equals(json.substring(json.length() - 1))) {
            return true;
        } else {
            return false;
        }
    }
}

Related Tutorials