匹配可能看起来像JSON的字符串

I have expression parser and I want to add json support so I need to match one of [ or { any number of characters that may include paired [] and {} and then ] or }.

So far I have ([[{])(.(?!\1))*[\]}] it match [foo} but I can live with that. Invalid json will be catch when json_decode return null.

I need to match JSON in strings like this:

{"foo":"bar"} == 20
[1,2,3,4] == 10

but also first JSON in those strings:

{"foo": "bar"}["foo"]
[1,[2],{"foo":"bar"},4][0]
{"foo": "bar"} == {"foo": "bar"}

So far I have regex like this ^([\[{](?>"(?:[^"]|\\")*"|[^\]}]|(?1))*[\]}]): demo but it don't match: [1,[2],{"foo":"bar"},4]

This is matching regex I found based on S-Expression regex from comment in this answer Extract s-expressions from a beginning of the string:

^([\[{](?>"(?:[^"]|\\")*"|[^[{\]}]|(?1))*[\]}])

https://regex101.com/r/cUkoVe/2