Determines if the specified string is JSON encoded.

Parameters:
NameTypeDescription
strstring

The string to be tested.

Since
  • 1.0.0
Returns:

Returns true if the specified string is JSON encoded. Returns false otherwise.

Type: 
boolean
Example
import { isJson } from "@gravityforms/utils";

function Example() {
  const str = '{"name":"John", "age":30}';
	 const isJsonEncoded = isJson( str );
}