I’ve three strings.
var ids = "1*2*3";
var Name ="John*Brain*Andy";
var Code ="A12*B32*C38";
I want to create a JavaScript object of it.
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.
A JSON object is just a string, so it would be:
If you want the strings converted into string arrays:
If you are not at all looing for JSON, but in fact a Javascript object, it would be:
Based on your description “I want first item of the array to be having three props i.e. Id, name and code with values 1,John, A12 respectively.” it would however be completely different:
And if you want that as JSON, it would be:
(Note: The last code only works properly when the strings doesn’t contain any quotation marks, otherwise they have to be escaped when put in the string.)