0

I'd like to return a struct which contains another struct.

When calling the function, I want to make the return result likely to

0:string: Username
1:string[]: [[a.doc,0x8c1ed7e19abaa9f23c476da86dc1577f1ef401f5],[b.doc,0x9dd1e8169e76a9226b07ab9f85cc20a5e1ed44dd]]

but get the return result is

0: tuple(string,tuple[]): Allen,

Here's my contract code:

Contract

pragma solidity >=0.4.22 <0.6.0;
pragma experimental ABIEncoderV2;
contract Test {
    struct UsrDoc {
        string tname;
        string addr;
    }

    struct User {
        string name;
        UsrDoc[] userdocs;
    }

mapping(uint => User) users;

function set(uint id, string memory _name,string memory _tname,string memory addrr)public {
    users[id].name = _name;
    users[id].userdocs.push(UsrDoc({tname:_tname,addr:addrr})) ;
}

function get(uint id) public view returns(User){
    return users[id];
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.