DescriptionUpdate base::JSONValueConverter to support custom actions.
The existing RegisterCustomField() method requires that the
caller provide a conversion function and specify the
location where the resulting value should be saved.
This change adds RegisterCustomAction() and
RegisterRepeatedCustomAction(), which can be used to add
handlers that perform arbitrary actions. For example, this
is useful if you have JSON like this:
{"link": [
{"type": "email",
"href": "me@example.org"},
{"type": "home",
"href": "http://www.example.org"}
]}
and you want to store it in a class like:
struct Links {
std::string email_href;
std::string home_href;
};
RegisterRepeatedCustomAction() can be used to register a
function that that receives a DictionaryValue for to each
element in the "link" list and saves its "href" field to the
appropriate member in Links depending on the value of the
"type" field.
BUG=128805
TEST=added
Patch Set 1 #
Total comments: 1
Patch Set 2 : rename constants in test #
Total comments: 1
Messages
Total messages: 2 (0 generated)
|