I have the following JSON string :
{"FirstName":"John","LastName":"Smith"}
When I apply the following regex, it correctly returns the key-value pair groups:
(?<keyValuePair>(?<key>"\w+"):(?<value>".*?[^\\]"+?))+?
I get the matches:
1. "FirstName":"John"
1.1 key:"FirstName"
1.2 value:"John"
2. "LastName":"Smith"
2.1 key:"LastName"
2.2 value:"Smith"
Now, I want to have a group for object, i.e. find all objects.. On the same JSON string, I apply the following regex
(?<object>{(?<properties>.*?)})
I get the matches:
1. {"FirstName":"John","LastName":"Smith"}
1.1 object : {"FirstName":"John","LastName":"Smith"}
1.2 properties : "FirstName":"John","LastName":"Smith"
What I want is the get the goups of the first regex as sub-groups of properties in the second regex.
So the expected result should be:
1. {"FirstName":"John","LastName":"Smith"}
1.1 object : {"FirstName":"John","LastName":"Smith"}
1.2 properties : "FirstName":"John","LastName":"Smith"
1.2.1 "FirstName":"John"
1.2.1.1 key : "FirstName"
1.2.1.2 value : "John"
1.2.2 "LastName":"Smith"
1.2.2.1 key : "LastName"
1.2.2.2 value : "Smith"
Could someone help me to create a regex to get the result as above.
This would not count as a duplicate
I have so far tried many things since the past 3 hours and my mind is spinning.