JSON Key-Value Pair
intermediateMatches key-value pairs in JSON format.
jsonparsingdatakey-value
Pattern
/"([^"\\]*(?:\\.[^"\\]*)*)"\s*:\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|-?\d+(?:\.\d+)?|true|false|null)/gTry It
0 of 7 strings matched
Explanation
Matches a JSON key (double-quoted string with escape handling) followed by colon and a value (string, number, boolean, or null).
Test Strings
Matching
- "name": "John"
- "age": 30
- "active": true
- "data": null
Non-matching
- name: John
- 'key': 'value'
- {"a": [1]}
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /"([^"\\]*(?:\\.[^"\\]*)*)"\s*:\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|-?\d+(?:\.\d+)?|true|false|null)/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);