Skip to content

Instantly share code, notes, and snippets.

@stevenroose
Last active August 21, 2018 09:21
Show Gist options
  • Save stevenroose/b5a9a79e84bb949b08112d560ccec9e0 to your computer and use it in GitHub Desktop.
Save stevenroose/b5a9a79e84bb949b08112d560ccec9e0 to your computer and use it in GitHub Desktop.
int UniValue::findKey(const std::string& key) const
{
for (unsigned int i = 0; i < keys.size(); i++) {
if (keys[i] == key)
return (int) i;
}
return -1;
}
const UniValue& UniValue::operator[](const std::string& key) const
{
if (typ != VOBJ)
return NullUniValue;
int index = findKey(key);
if (index < 0)
return NullUniValue;
return values.at(index);
}
const UniValue& find_value(const UniValue& obj, const std::string& name)
{
for (unsigned int i = 0; i < obj.keys.size(); i++)
if (obj.keys[i] == name)
return obj.values.at(i);
return NullUniValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment