I've got the following regex..
(^\[[.*][[0-9a-zA-Z][0-9a-zA-Z]]*[.*]\])
which is meant to only match non-empty JSON encoded strings like so...
[ { object: HELLO } ]
while excluding "empty" JSON responses such as...
[ ]
These responses may or may not have whitespace in them.
My regex seems to work for some cases i.e..
[ ] <---- does not match.
[ HELLO ] <---- matches.
[ { HELLO } ] <---- does not match.
I'm not so much concerned about the actual validity of the JSON but rather making sure that there is something other than white space within the []
What would be the best way of checking that?
[ { object: HELLO } ]is not JSON btw. Since JSON is contains nested structures, you'd need a recursive regex engine.