public static boolean mayBeJSON( String string ) {
      return string != null
            && ("null".equals( string )
                  || (string.startsWith( "[" ) && string.endsWith( "]" )) || (string.startsWith( "{" ) && string.endsWith( "}" )));
   }
public static boolean mayBeJSON ( String string ) { return string != null && ( "null" . equals ( string ) || ( string . startsWith ( "[" ) && string . endsWith ( "]" ) ) || ( string . startsWith ( "{" ) && string . endsWith ( "}" ) ) ) ; }
Tests if the String possibly represents a valid JSON String.<br>
Valid JSON strings are:
<ul>
<li>"null"</li>
<li>starts with "[" and ends with "]"</li>
<li>starts with "{" and ends with "}"</li>
</ul>