I have a json object
eg
{
"href":"Test",
"commentID":"12334556778"
}
Is there a way just to get the second line i.e. “commentID”:”12334556778″
I’m using
JSON.stringify(json)
Thanks all
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.
JSON.stringifyaccepts a third argument which handles white-space in the output. If the third argument is present and “truthy”, line-breaks will be inserted and each level will be indented using the argument’s string value, or a number of spaces if a number is passed. Using this technique, you can get the browser to insert line-breaks and then split on those line-breaks in the result:You might want to trim any leading white space or trailing comma, but I’ll leave that up to you.