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