Custom Data Structure as Argument in Solidity functions

I am trying to pass a JSON like data structure as an argument to a function which can be traversed to intitialize a struct.

Although I looked into a few codes , I didn’t find an effective procedure to do it.

How exactly can I pass a json-like custom data structure in Solidity functions , so that I can use a for loop to traverse over it and use the passed values to intitialize a struct.

Please provide useful resources to help me out with this.

1 Like

Hi @zaryab2000,

Due to the cost of doing this onchain, I would off load the work as much as possible offchain. You should look at providing the data in a ready to use format.

We should avoid loops where every possible on chain, due to expense and the potential to run out of gas for unbounded loops.