Uses JSON.parse() to transform a string in query format (i.e. query1=val&query2=val2 ) into an object.

Parameters:
NameTypeDescription
paramsstring

The query style string to be parsed. If ommitted, the query portion of the current URL is used.

Since
  • 1.0.0
Returns:

Returns an object based on the specified params or the current URL's query portion.

Type: 
object
Example
import { queryToJson } from "@gravityforms/utils";

function Example() {
  const params = 'query1=val1&query2=val2';
	 const obj = queryToJson( params );
}