John Davidson

javascript - PHP json_encode() Adding an Apostrophe at Pos 0

0 comments
Message:


I have a very strange issue. I have been working on a project for months with no issues. Today I was coding on the API side of the project and suddenly my json string is returning with a ' at position 0.


The weird part is I have not touched that code for a while. To test I made the API return


die(json_encode('hi'));

Which returns: '"hi" ,but when I try to have javascript parse it using:


server.data = JSON.parse(server.data);

I get the following error:


Unexpected token ' in JSON at position 0

I am at a complete loss because nothing has changed on my code. I even rolled back to a commit that was working fine yesterday and still the same issue. Does anyone have a direction they can point me in?



My Answer:
hi

Rate this post

4 of 5 based on 4010 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us