Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How can I clean Dirty JSON String format ?
For Example from this String
{"AS_applicant_Data__c":"{\\\"Full Name\u00a0\\\":\\\"asdffas\\\"}"}
to this format
{"AS_applicant_Data__c":"{"Full Name":"asdffas"}"}
stripslashes
\u00a0
Use str_replace to remove all occurrences of \ and u00a0 from your json string, like this:
str_replace
\
u00a0
echo str_replace('u00a0', '', str_replace('\\', '', $json_string));
Output:
AS_applicant_Data__c":"{"Full Name":"asdffas"}"}
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
stripslashes, but you have\u00a0in the original string. Where did you get this string?