Q: How can I find Json data inside other strings? I need to analyze a string using JavaScript to determine whether or not it contains some JSON anywhere within it.
I have a pattern that works on RegEx 101 and in PHP:
$pattern = '
/
\{              # { character
(?:         # non-capturing group
        [^{}]   # anything that is not a { or }
        |       # OR
        (?R)    # recurses the entire pattern
    )*          # previous group zero or more times
\}              # } character
/x
';

preg_match_all($pattern, $text, $matches);
print_r($matches[0]);

I am struggling, however, to convert it to JavaScript.  Here is what I have so far:
 var txt = draft.content. // gets a long text string
 jsontest = txt.match(/\{(?:[^{}]|(?R))*\}/xg);

But that gets an error that says:

invalid character in regular expression after (?

Can anyone suggest a modification to that regex pattern? Or is there another way to do this in JavaScript that wouldn't require regex?
Here is the input:
 New test nested braces

 {
 "employee":{ "name":"John", "age":30, "city":"New York" },
 "location":{"street":"100 Main","City":"Houston","Zip":"77001"}
 }

 And other text that is not part of the string I need 

The output should be the json string 

A: Ok taking your "input" at face value:
New test nested braces

 {
 "employee":{ "name":"John", "age":30, "city":"New York" },
 "location":{"street":"100 Main","City":"Houston","Zip":"77001"}
 }

 And other text that is not part of the string I need 

this Regex will match what you want
/{[{}\w\":\s,]*}/g

https://regexr.com/3iqvb

A: I found another solution or kludge
 {(?<={).*(?=})}

Gets the first and last curly brace and everything in between. 
That certainly doesn't mean that the matched string is JSON compliant and it could return 
{"a":"1","b"."2"} Some junk here {"c":"1","d"."2"}
As one string. But I know my source and am confident that it will get complex JSON
I prefer Liam's solution but desperate solutions sometimes work too. 
https://regex101.com/r/DKzfuS/1

A: I can see that the sample I provided was pretty basic but @Liam 's answer was perfect for it and taught me how to get started. 
I found an example of more robust JSON including arrays in brackets, email addresses etc so I extended his solution to:
 /{[{}\[\]\w\!@#\$%\^\&*\)\(+=._":@\?\-\s,]*}/g

I look for more special characters. I realize that it is incomplete so caveat emptor. 
https://regex101.com/r/xzgpwe/4

A: OK newby shame here. My original question was overwrought and over thought. 
The answer offered (without me providing proper context) is correct. 
But this is simpler especially if you have confidence that the JSON like string was properly generated or can be properly validated. 
 {.*}

See the test string in the example here
https://regex101.com/r/37AUap/1/
