I'm implementing some kind of parser and I need to locate and deserialize json object embedded into other semi-structured data. I used regexp:
\\{\\s*title.*?\\}
to locate object
{title:'Title'}
but it doesn't work with nested objects because expression matches only first found closing curly bracket. For
{title:'Title',{data:'Data'}}
it matches
{title:'Title',{data:'Data'}
so string becomes invalid for deserialization. I understand that there's a greedy business coming into account but I'm not familiar with regexps. Could you please help me to extend expression to consume all available closing curly brackets.
Update:
To be clear, this is an attempt to extract JSON data from semi-structured data like HTML+JS with embedded JSON. I'm using GSon JAVA lib to actually parse extracted JSON.