I must store JSON formatted data in my Solidity contract. I don't need to do any operations on the data. I simply need to store it, update it, and return it.
Let's say I have JSON formatted data such as:
{'name': 'Nike', 'size':'12', 'color':'blue'}
I'm currently passing the data to the constructor as a string:
constructor(string _data) public {
data = _data;
}
And updating the data by simply replacing the entire string:
function updateData(string _data) public {
data = _data;
}
I'm debating whether I should create a Struct type, named say "Shoe", and pass each property as an argument:
constructor(string _name, uint size, string _color) public {
Shoe memory newShoe = Shoe({
name: _name,
size: _size,
color: _color
})
data = newShoe;
}
I'll never need to store more than one shoe object, and it seems much simpler and easier to pass the data as a String, but I'm wondering if there's an advantage to using a Struct type.