Here you can find the source of isJSONValid(final String json)
public static boolean isJSONValid(final String json)
//package com.java2s; //License from project: Open Source License import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; public class Main { public static boolean isJSONValid(final String json) { boolean valid = false; try {/*from ww w . j a va 2 s .c om*/ final JsonParser parser = new ObjectMapper().getFactory().createParser(json); while (parser.nextToken() != null) { // empty! } valid = true; } catch (JsonParseException jpe) { jpe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } return valid; } }