Blockchain – How to Store and Retrieve a JSON Object in the Blockchain

blockchain

Relative blockchain newbie here (go easy on me please:)

Let's say I have a JSON object that contains:

  1. UPC code
  2. Product name
  3. Product color
  4. Product size

Could I store this object in the blockchain–and then retrieve it by UPC?

Now let's say I have a few hundred million of these, with thousands of new ones being created daily.

Possible? What's the process?

Best Answer

You can store JSON as a string. see this fiddle: https://ethfiddle.com/u8SvB0QMgE

enter image description here

You can also store a mapping of string->string which could be used if you wanted to retrieve JSON data by key. But Ethereum isn't a JSON-database and you won't be able to search within you JSON data without retrieving it first.

As for you second question, you can store millions of these as long as you can pay for it

Related Topic