//pragma solidity ^0.5.1;
pragma experimental ABIEncoderV2;
contract SearchPeopleInfo{
uint _TransactionIDx;
bytes[] peoplelocations;
bytes[] existtime;
struct PeopleInfo{
uint peopleID;
bytes peopleLocation;
bytes ExistTime;
}
mapping(uint => PeopleInfo) public _peopleInfo;
uint[] public _pendingPeopleInfo;
function EnterInfo(uint peopleID, string memory stringpeopleLocation, string memory stringExistTime)public {
uint TransactionID=_TransactionIDx++;
PeopleInfo memory peopleInfo;
peopleInfo.peopleID=peopleID;
peopleInfo.peopleLocation=bytes(stringpeopleLocation);//string to bytes
peopleInfo.ExistTime=bytes(stringExistTime);//string to bytes
_peopleInfo[TransactionID]=peopleInfo;
_pendingPeopleInfo.push(TransactionID);
}
function searchInfo(uint _peopleID)public {
delete peoplelocations;
delete existtime;
for (uint i=0;i<=_pendingPeopleInfo.length;i++){
if (_peopleInfo[i].peopleID==_peopleID){
peoplelocations.push(_peopleInfo[i].peopleLocation);
existtime.push(_peopleInfo[i].ExistTime);
}
}
}
function getInfo( )public view returns (bytes[] memory,bytes[] memory){
return(peoplelocations,existtime);
}
}
函数getInfo()返回两个bytes[],分别为peoplelocations以及existtime,能否在solidity中将这两个bytes[]转化为字符串数组string[]?