Help with web_reg_save_param_regexp
I am working on a commerce page that returns a list of multiple products, and has the following (potential) output fields for each item:
"itemAvailabilityDate":"2014-07-01 00:00:00.0","itemAvailableInventory":28.0,"buyable ":1,"published":1,"prodId":446726,"partNumber":"i_ 62064 COU BLA","listPrice":99.00
I need to retrieve the itemAvailabilityDate, itemAvailableInventory, buyable, and prodId portions of the above text, the challenge is that
1) Sometime the page contains "hidden" items" that may have one or more of the fields listed, but not all
2) The item attributes are not always in the order listed above
My original thought was to setup a web_reg_save_param_regexp to handle things (including issue 1), but then I ran into issue #2 .
As far as I am aware, web_reg_save_param_regexp is not able to handle "randomly ordered" items, is it?
The only other method I can think of is to retrieve the whole set into an array, parse that array for only the items that contain all the required fields, then grab the required field information from those fields.
Can anyone think of a simpler method for doing the same thing?
I've run into similar scenarios once or twice before. And I ended up grabbing everything, and walking through it line by line looking for some key substring. Once I found that, I knew I had the line I needed. Definitely unpleasant, but it worked.
What about if you create four separate "web_reg_save_param" (one for each item you want to capture). In this case the random order should not be relevant. The left boundary can be LB=\"itemAvailabilityDate\":\" and the right boundary can be RB=\",
When you talk about hidden items does that mean that one of the four elements you want to capture is not present or that hidden items are some more elements that may occur or not?