0

I know the JSON.parse() method that will convert valid json string to Javascript object. But I have the below string that and when I tried to parse that string using JSON.parse() it throws an error SyntaxError: Unexpected token

{ "test" : 
[
    {
        "first_name": "Sammy",
        "last_name" : "Shark",
        "online"    : true,
        "full_name" : function() {
           return this.first_name + " " + this.last_name;
        }
    }
]

}

now as you can see the above json string contains the function full_name() that is why it throws an error. Please provide any suggestion to handle this scenario.

Any suggestions would be highly appreciated !

Thanks

prog1011
  • 3,425
  • 3
  • 30
  • 57
  • 2
    JSON cannot have functions. Only string, number, object, array, booealn and null are allowed https://www.json.org/ – adiga Feb 06 '19 at 09:27
  • Possible duplicate of [Is it valid to define functions in JSON results?](https://stackoverflow.com/questions/2001449) – adiga Feb 06 '19 at 09:28
  • @str Is there any other parser available? that can parse this string – prog1011 Feb 06 '19 at 09:35

0 Answers0