-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Expression like the following: $.Manufacturers..[?(@Products[?(@Name=='Elbow Grease')])] are not parsed correctly.
In Normalize the following code exists
RegExp.Replace(expr, @"[\['](\??\(.*?\))[\]']", m =>
This regex is not greedy, so the .* will match the minimum it can, so ?(@Products[?(@Name=='Elbow Grease') is matched, not ?(@Products[?(@Name=='Elbow Grease')])
Making it greedy doesn't solve all the problems either.
We could make it match the simple case (no internal sub expressions) and once matched, and replaced with a [#1] subsequently repeat the process until the string no longer changes.
Even once we get that working... we need to handle escaping of strings... What if Elbow Grease was a barcode that included a ')'.
My test data was as follows...
{
'Stores': [
'Lambton Quay',
'Willis Street'
],
'Manufacturers': [
{
'Name': 'Acme Co',
'Products': [
{
'Name': 'Anvil',
'Price': 50
}
]
},
{
'Name': 'Contoso',
'Products': [
{
'Name': 'Elbow Grease',
'Price': 99.95
},
{
'Name': 'Headlight Fluid',
'Price': 4
}
]
}
]
}
Metadata
Metadata
Assignees
Labels
No labels