So I'm writing a static validator for a particular kind of file. These files are expected to have a certain JSON-like object in it. Sample below
theObject = {
key1 = value1,
key2 = value2,
key3 = {
key4 = value4,
key5 = value5
}
}
There are a lot of other things in this file but this is required and I need to validate its presence and form. My current solution to this has been to find the 2nd } after theObject's name and extract out the guts of the object so I can stick it in a JSON parser. Obviously this fails if the creator fails to include key3 entirely.
I've been trying to tweak a regex to fit the form
m/theObject = (\{.*\})/
Obviously this doesn't work. Any ideas on how to match the corresponding closing bracket to the expected opening bracket?