Parsing JSON Strings

The Importance of Quotation Marks

When parsing JSON data, a key or a string value is always wrapped between double quotation marks. This is our cue to focus on them.

The Parsing Technique

We use slice(1, -1) to get the content between the quotation marks, and we check if the first character is a quotation mark (") to know when to do this.

JAVASCRIPT
1if (input[0] === '"') {
2    return input.slice(1, -1);
3}