I am having users enter a JSON object into a text field and want to check to make sure it has a similar format to this:
{
"address": "some string",
"msg": "some string",
"sig": "some string",
"version": "some string"
}
I want it to start with {
and end with }
and check for "address"
, "msg"
, "sig"
, and "version"
.
So far I have this which works if it's in that exact format:
^{.*"address".+,.*"msg".+,.*"sig".+,.*"version".+}$
However, I would like the keys to be valid in any order. From my understanding, (?=)
is used to search a forward looking string, I've tried the following and it doesn't seem to work....
^{.*(?="address".+,)(?="msg".+,)(?="sig".+,)(?="version".+).*}$
What am I getting wrong here?