I have a string here:
{eventStart: "2018/12/01",eventEnd: "2018/12/01"}
I want to check if this can make a valid js object or not. Like if want to make an ajax call we write like this :
$.ajax({
type: "post",
url: "something",
data: data
})
if we miss a comma or inverted comma there is a syntax error. I want to check it in php if the string can make a valid js object or not.
Above example, will check only for
{
type: "post",
url: "something",
data: data
}
EDIT
I can check for valid json but for valid json in json_decode function, it should be like this :
{
"type": "post",
"url": "something",
"data": data(valid object here)
}
but when we write code we do just this
{
type: "post",
url: "something",
data: data
}
json_encodethe php object into valid JSON, it'll be able to become a valid JS object.data(valid object here)not getting stringified correctly before it gets posted to the php?