I have this smart contract:
pragma solidity 0.5;
pragma experimental ABIEncoderV2;
contract TestStruct {
struct User {
string name;
uint256 age;
}
mapping (bytes32 => User) users;
function addUsers (User [] memory _users) public {
for (uint i = 0; i < _users.length; i++) {
bytes32 hash = keccak256(abi.encode(_users[i].name));
users[hash] = _users[i];
}
}
function getUser (string memory username) public view returns (User memory) {
bytes32 hash = keccak256(abi.encode(username));
return users[hash];
}
}
I want to test it using remix IDE, But I didn't find the write way to pass the array of struct in remix UI
And I got this error:
transact to TestStruct.addUsers errored: Error encoding arguments: SyntaxError: JSON.parse: expected property name or '}' at line 1 column 4 of the JSON data