Skip to content

Instantly share code, notes, and snippets.

@dancojocaru2000
Created July 27, 2022 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancojocaru2000/4e582cc081e17c2560d6445998183be4 to your computer and use it in GitHub Desktop.
Save dancojocaru2000/4e582cc081e17c2560d6445998183be4 to your computer and use it in GitHub Desktop.
Check keys
final json = [
{
"name": "to",
"type": "address",
},
{
"name": "tokenId",
"type": "uint256",
},
];
void main() {
final toCheck = {
"to": "1",
"tokenId": 1,
};
final keysNotInToCheck = json.map((v) => v["name"]).where((k) => !toCheck.keys.contains(k)).toList();
if (keysNotInToCheck.isNotEmpty) {
print('Keys missing in toCheck: ${keysNotInToCheck.join(', ')}');
}
else {
print('All good!');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment