How to store Json data within stream

+1 vote

I am new to multichain. I am trying to store json with stream.Consider sample json as below.

	"id": "0001",
	"type": "donut",
	"name": "Cake",
					{ "id": "1001", "type": "Regular" },
					{ "id": "1002", "type": "Chocolate" }
			{ "id": "5001", "type": "None" },
			{ "id": "5002", "type": "Glazed" }
How to store this data in stream.Any suggestion will be greatful.
asked Sep 21, 2017 by haresh

2 Answers

+3 votes

What I did was two extra steps:

  1. convert the json to a string (usually a method called json.stringify or something similar depending on the language you program in)
  2. convert the result of step 1 to hexadecimal
  3. store the hexadecimal data in the stream through the publish call.
if you're doing all this in your terminal you need to use a different tool to first convert your json to a string, and then your string to hexadecimal
answered Sep 21, 2017 by Rachelle
+2 votes

At the moment you can't store plain json in a stream, though I believe it's a feature planned for the 2.0 version. What you need to do is convert your json to hexadecimal data, and use the publish function to store it in a stream, look up the how this command works here, in the  "Publishing stream items" section.

answered Sep 21, 2017 by Bric3d