I know the method to convert a JS object into a JSON string by using JSON.stringify(object) method. How can I encode a string object into JSON?
I know the method to convert a JS object into a JSON string by
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t convert a string into JSON. The outermost data type in JSON must be an object or an array.
See the specification:
You could wrap the string in an object or array and then serialise that:
Whatever processed it would have to know that after parsing the JSON it would have to extract the string from it though.