{
"ask": {
"amount": 0,
"assets": [
{
"assetref": "74-266-27408",
"name": "USD",
"qty": 5000
}
]
},
"cancomplete": true,
"candisable": true,
"complete": false,
"offer": {
"amount": 0,
"assets": [
{
"assetref": "73-266-61482",
"name": "BTC",
"qty": 1
}
]
},
"requiredfee": 0
}
type order struct {
ask `json:"ask"`
Cancomplete bool `json:"cancomplete"`
Candisable bool `json:"candisable"`
Complete bool `json:"complete"`
offer `json:"offer"`
Requiredfee float64 `json:"requiredfee"`
}
type ask struct {
Ammount float64 `json:"ammount"`
assets `json:"assets"`
}
type offer struct {
Ammount float64 `json:"ammount"`
assets `json:"assets"`
}
type assets struct {
Assetref string `json:"assetref"`
Name string `json:"name"`
Qty float64 `json:"qty"`
}
func DecodeOrder(datahex string) (*order){
var order *order
err := rpcClient.CallFor(&order, "decoderawexchange", datahex)
if err != nil || order == nil {
// handle error }
fmt.Print(order)
return order
}
<nil>
package main
import (
"encoding/json"
"log"
)
type assetJSON struct {
AssetRef string
Name string
Qty float64
}
type assetsJSON struct {
Amount float64
Assets []assetJSON
}
type objectJSON struct {
Ask assetsJSON
CanComplete bool
CanDisable bool
Complete bool
Offer assetsJSON
RequiredFee float64
}
func main() {
jsonData := []byte(`{
"ask": {
"amount": 0,
"assets": [
{
"assetref": "74-266-27408",
"name": "USD",
"qty": 5000
}
]
},
"cancomplete": true,
"candisable": true,
"complete": false,
"offer": {
"amount": 0,
"assets": [
{
"assetref": "73-266-61482",
"name": "BTC",
"qty": 1
}
]
},
"requiredfee": 0
}`)
obj := objectJSON{}
if err := json.Unmarshal(jsonData, &obj); err != nil {
log.Fatal(err)
}
log.Printf("%#v", obj)
}
type Order struct {
Ask struct {
Amount float64 `json:"amount"`
Assets []struct {
Assetref string `json:"assetref"`
Name string `json:"name"`
Qty float64 `json:"qty"`
} `json:"assets"`
} `json:"ask"`
Cancomplete bool `json:"cancomplete"`
Candisable bool `json:"candisable"`
Complete bool `json:"complete"`
Offer struct {
Amount float64 `json:"amount"`
Assets []struct {
Assetref string `json:"assetref"`
Name string `json:"name"`
Qty float64 `json:"qty"`
} `json:"assets"`
} `json:"offer"`
Requiredfee float64 `json:"requiredfee"`
}