create account

Attention Bitshares Developers: I need help with JSON Trade Data. by pairmike

View this thread on: hive.blogpeakd.comecency.com
· @pairmike · (edited)
$7.36
Attention Bitshares Developers: I need help with JSON Trade Data.
<center>![enter image description here](https://lh3.googleusercontent.com/nmlrjIf9F9x4UaZaCVoS60PZX7j6EpGl2tMzMclIR_ntKgkrdISwSR-Pk-nf7jdS9P6R6iywjBKvFw=s300)</center>
</center>[Image Credit](https://coincentral.com/what-is-bitshares/)</center>

### Attention Developers:  I need help with Openledger Json Trade Data.

I'm trying to determine how to convert the following JSON trade fill data, so that I can create an entry into [Cointracking.info](https://cointracking.info?ref=P204019) coin detail.  

Can anyone help?

[4,
{
"fee":{"amount":2000,"asset_id":"OPEN.EOS"},
"order_id":"1.7.62838114",
"account_id":"1.2.2503",
"pays":{"amount":4700001,"asset_id":"BTS"},
"receives":{"amount":1000000,"asset_id":"OPEN.EOS"},
"fill_price":{"base":{"amount":157093302,"asset_id":"OPEN.EOS"},
"quote":{"amount":738338519,"asset_id":"BTS"}},
"is_maker":false}]

Thanks,

 [@pairmike](https://steemit.com/@pairmike)

Please Remember to UpVote - ReSteem - Comment

----------------
<center><a target="_blank" href="https://www.amazon.com/gp/search?ie=UTF8&tag=lifinvmusande-20&linkCode=ur2&linkId=93907f7fcc9aac485154fd7621f57cb6&camp=1789&creative=9325&index=aps&keywords=gifts">Support Me By Shopping at Amazon</a><img src="//ir-na.amazon-adsystem.com/e/ir?t=lifinvmusande-20&l=ur2&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></center>
👍  , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorpairmike
permlinkattention-developers-i-need-help-with-openledger-json-trade-data
categorybitshares
json_metadata{"tags":["bitshares","trade","openledger","development","json"],"image":["https://lh3.googleusercontent.com/nmlrjIf9F9x4UaZaCVoS60PZX7j6EpGl2tMzMclIR_ntKgkrdISwSR-Pk-nf7jdS9P6R6iywjBKvFw=s300","//ir-na.amazon-adsystem.com/e/ir?t=lifinvmusande-20&l=ur2&o=1"],"links":["https://coincentral.com/what-is-bitshares/","https://cointracking.info?ref=P204019","https://steemit.com/@pairmike","https://www.amazon.com/gp/search?ie=UTF8&tag=lifinvmusande-20&linkCode=ur2&linkId=93907f7fcc9aac485154fd7621f57cb6&camp=1789&creative=9325&index=aps&keywords=gifts"],"app":"steemit/0.1","format":"markdown"}
created2018-04-17 23:40:30
last_update2018-04-18 01:15:09
depth0
children7
last_payout2018-04-24 23:40:30
cashout_time1969-12-31 23:59:59
total_payout_value6.065 HBD
curator_payout_value1.290 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,385
author_reputation43,927,661,974,027
root_title"Attention Bitshares Developers: I need help with JSON Trade Data."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,654,729
net_rshares1,458,065,783,344
author_curate_reward""
vote details (24)
@anniversary ·
<center>![post.JPG](http://res.cloudinary.com/duvrfxmpc/image/upload/v1510241264/2-Year_py3dwj.jpg)<h1>Congratulation</h1><b>Today 2 years ago you joined SteemIt
 Thank you, for making SteemIt great and Steem on for more years to come!</b>
 (You are being celebrated  [here](/steemit/@anniversary/20180423t030020704z-celebration-post))<br/></center>
properties (22)
authoranniversary
permlink20180423t030825944z
categorybitshares
json_metadata{"tags":["comment"],"app":"steemjs/comment"}
created2018-04-23 03:08:27
last_update2018-04-23 03:08:27
depth1
children0
last_payout2018-04-30 03:08:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length351
author_reputation1,856,978,117,082
root_title"Attention Bitshares Developers: I need help with JSON Trade Data."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id51,594,024
net_rshares0
@kenny-crane · (edited)
$3.36
Hiya!  Not sure if this is what you are looking for, but first, that is valid JSON.  And you can play with it in the console of your browser by hitting F12 and going to the console tab.  If you paste in

`var arr = [4,
{
"fee":{"amount":2000,"asset_id":"OPEN.EOS"},
"order_id":"1.7.62838114",
"account_id":"1.2.2503",
"pays":{"amount":4700001,"asset_id":"BTS"},
"receives":{"amount":1000000,"asset_id":"OPEN.EOS"},
"fill_price":{"base":{"amount":157093302,"asset_id":"OPEN.EOS"},
"quote":{"amount":738338519,"asset_id":"BTS"}},
"is_maker":false}]; arr[1].fee.amount`

it will return 2000.

I think if you put that json in a validator you will see its structure more clearly:

https://jsonlint.com/

If you have any question on how to get to any other value in this json, let me know and I'll get it for you.  But basically, assign that to a js variable, like arr, and then get what you need by starting with

`arr[1].firstLevel.secondLevel.thirdLevel` 

replacing firstLevel, etc with the name of the variable.
👍  
properties (23)
authorkenny-crane
permlinkre-pairmike-attention-developers-i-need-help-with-openledger-json-trade-data-20180418t000352804z
categorybitshares
json_metadata{"tags":["bitshares"],"links":["https://jsonlint.com/"],"app":"steemit/0.1"}
created2018-04-18 00:03:51
last_update2018-04-18 00:20:51
depth1
children5
last_payout2018-04-25 00:03:51
cashout_time1969-12-31 23:59:59
total_payout_value2.518 HBD
curator_payout_value0.838 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,010
author_reputation234,049,185,243,091
root_title"Attention Bitshares Developers: I need help with JSON Trade Data."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,657,175
net_rshares665,607,830,800
author_curate_reward""
vote details (1)
@pairmike ·
$0.31
Hey Kenny,  

I know it not valid Json.  What I'm really looking for is to understand how to convert this info into something like this:

Type	Buy	Cur.	Sell	Cur.	Fee	Cur.	Exchange	Group	Comment	Date
Trade	4.46672378	LTC	978.90708337	USD	2.92793744	USD	GDAX			2018-02-15 09:00:44
👍  
properties (23)
authorpairmike
permlinkre-kenny-crane-re-pairmike-attention-developers-i-need-help-with-openledger-json-trade-data-20180418t002249082z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-04-18 00:22:48
last_update2018-04-18 00:22:48
depth2
children4
last_payout2018-04-25 00:22:48
cashout_time1969-12-31 23:59:59
total_payout_value0.230 HBD
curator_payout_value0.076 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length278
author_reputation43,927,661,974,027
root_title"Attention Bitshares Developers: I need help with JSON Trade Data."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,659,427
net_rshares61,598,608,096
author_curate_reward""
vote details (1)
@kenny-crane ·
Are you getting this data from a javascript program or are you using something else?

In js, the Buy Currency would be 

`arr[1].receives.amount + ' ' + arr[1].receives.asset_id`

I would think.  

cointracking.info says they have "Automatic import via APIs" so I would think there would already be some automatic way to do this, but I'm not familiar with BitShares/OpenLedger APIs.  I imagine they have APIs and they probably look like Steemit APIs, but I'd have to look into it.  I assume what you show here is the result of a BitShares API call, but maybe cointracking does not support this API?
properties (22)
authorkenny-crane
permlinkre-pairmike-re-kenny-crane-re-pairmike-attention-developers-i-need-help-with-openledger-json-trade-data-20180418t005139223z
categorybitshares
json_metadata{"tags":["bitshares"],"app":"steemit/0.1"}
created2018-04-18 00:51:39
last_update2018-04-18 00:51:39
depth3
children3
last_payout2018-04-25 00:51:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length598
author_reputation234,049,185,243,091
root_title"Attention Bitshares Developers: I need help with JSON Trade Data."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id50,662,691
net_rshares0