I have a large JSON file returned from a web service. I am using json_last_error() to get the error code, but would like to know which string is giving the error so that I can design a regex for it. How would I return the string giving the error?
Asked
Active
Viewed 2,421 times
2 Answers
2
Php doesn't have a function to validate json and find the error :(. Fortuanly there is a website (https://jsonformatter.curiousconcept.com/) that can do that.
Ps: make sure that you have checkt the validate checkbox :)
- Marnix
Marnix Bouhuis
- 455
- 1
- 6
- 15
0
I know I'm late, but I was researching about this and my solution was this library: https://github.com/Seldaek/jsonlint
With this library you can check the syntax of a JSON string and it gives you more detail than json_last_error() method do.
Greetings!
José Manuel Blasco
- 625
- 9
- 18