A .NET regular expression for extracting a single root-level JSON block from text.
Supports:
{ ... }[ ... ]// .../* ... */This regex performs structural matching only. It validates balanced braces/brackets and ignores delimiters inside strings and comments.
json group.This is not a full JSON parser.
It does not validate:
Use a real JSON parser after extracting the block.
Requires a regex engine with balancing group support:
System.Text.RegularExpressionsreInput:
// config
{
"name": "example",
"items": [
1,
2
]
}
Results:
Groups["json"] -> { "name": "example", "items": [1, 2] }