parent
4994d875fe
commit
e8470b2299
@ -1,41 +0,0 @@ |
||||
package explorer |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"fmt" |
||||
"io/ioutil" |
||||
"os" |
||||
) |
||||
|
||||
// ReadFakeData ...
|
||||
func ReadFakeData() Data { |
||||
jsonFile, err := os.Open("./fake_data.json") |
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
|
||||
// defer the closing of our jsonFile so that we can parse it later on
|
||||
defer jsonFile.Close() |
||||
|
||||
// read our opened xmlFile as a byte array.
|
||||
byteValue, err := ioutil.ReadAll(jsonFile) |
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
|
||||
// we initialize our Users array
|
||||
var data Data |
||||
|
||||
// we unmarshal our byteArray which contains our
|
||||
// jsonFile's content into 'users' which we defined above
|
||||
err = json.Unmarshal(byteValue, &data) |
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
|
||||
return data |
||||
} |
@ -1,72 +0,0 @@ |
||||
{ |
||||
"blocks": [ |
||||
{ |
||||
"id": "0000000000000000001c48da2a21c9d098efcab0f4904ff4773c0896c63c62f8", |
||||
"height": "553254", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"txCount": "2985", |
||||
"size": "917273" |
||||
}, |
||||
{ |
||||
"id": "000000000000000000271c579c88555b439e108261ba096ab217c4b0e5c5a929", |
||||
"height": "553253", |
||||
"timestamp": "Dec 10, 2018 1:11:45 AM", |
||||
"txCount": "2224", |
||||
"size": "898989" |
||||
} |
||||
], |
||||
"block": { |
||||
"height": "553254", |
||||
"hash": "0000000000000000001c48da2a21c9d098efcab0f4904ff4773c0896c63c62f8", |
||||
"txCount": "2985", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"merkleRoot": "14e349accb6320743b6655b1686a883e4e40d6d36ad08f31a22a4b1d4a6495e1", |
||||
"prevBlock": { |
||||
"id": "000000000000000000271c579c88555b439e108261ba096ab217c4b0e5c5a929", |
||||
"height": "553253" |
||||
}, |
||||
"bits": "1731d97c", |
||||
"bytes": "917273", |
||||
"nextBlock": { |
||||
"id": "0000000000000000001eea8340ae29cbe73173dff65ae44f6ec204cd11c10034", |
||||
"height": "553255" |
||||
}, |
||||
"txs": [ |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0a4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3c65970996d7de5a65d66915a1772481a4a00a61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 20 |
||||
} |
||||
] |
||||
}, |
||||
"address": { |
||||
"hash": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"balance": 0.412535411, |
||||
"txCount": 29, |
||||
"txs": [ |
||||
{ |
||||
"id": "0xc67298b46c474bdfe53e0a4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
}, |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0aa4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
}, |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0fa4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
} |
||||
] |
||||
} |
||||
} |
@ -1,72 +0,0 @@ |
||||
{ |
||||
"blocks": [ |
||||
{ |
||||
"id": "0000000000000000001c48da2a21c9d098efcab0f4904ff4773c0896c63c62f8", |
||||
"height": "553254", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"txCount": "2985", |
||||
"size": "917273" |
||||
}, |
||||
{ |
||||
"id": "000000000000000000271c579c88555b439e108261ba096ab217c4b0e5c5a929", |
||||
"height": "553253", |
||||
"timestamp": "Dec 10, 2018 1:11:45 AM", |
||||
"txCount": "2224", |
||||
"size": "898989" |
||||
} |
||||
], |
||||
"block": { |
||||
"height": "553254", |
||||
"hash": "0000000000000000001c48da2a21c9d098efcab0f4904ff4773c0896c63c62f8", |
||||
"txCount": "2985", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"merkleRoot": "14e349accb6320743b6655b1686a883e4e40d6d36ad08f31a22a4b1d4a6495e1", |
||||
"prevBlock": { |
||||
"id": "000000000000000000271c579c88555b439e108261ba096ab217c4b0e5c5a929", |
||||
"height": "553253" |
||||
}, |
||||
"bits": "1731d97c", |
||||
"bytes": "917273", |
||||
"nextBlock": { |
||||
"id": "0000000000000000001eea8340ae29cbe73173dff65ae44f6ec204cd11c10034", |
||||
"height": "553255" |
||||
}, |
||||
"txs": [ |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0a4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3c65970996d7de5a65d66915a1772481a4a00a61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": "20" |
||||
} |
||||
] |
||||
}, |
||||
"address": { |
||||
"hash": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"balance": 0.412535411, |
||||
"txCount": 29, |
||||
"txs": [ |
||||
{ |
||||
"id": "0xc67298b46c474bdfe53e0a4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
}, |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0aa4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
}, |
||||
{ |
||||
"id": "0xc67298b46c474bd7e53e0fa4521b27e2fedc14fc6d67973c72eed4c139496c1ba", |
||||
"timestamp": "Dec 10, 2018 1:43:43 AM", |
||||
"from": "0x3C65970996D7De5a65D66915A1772481a4a00A61", |
||||
"to": "0xe6b3a12cae421d928fa1ca4fb09f2be91afdf650", |
||||
"value": 10 |
||||
} |
||||
] |
||||
} |
||||
} |
@ -1,41 +0,0 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"fmt" |
||||
"io/ioutil" |
||||
"os" |
||||
|
||||
"github.com/harmony-one/harmony/services/explorer" |
||||
) |
||||
|
||||
func main() { |
||||
jsonFile, err := os.Open("./fake_data.json") |
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
|
||||
// defer the closing of our jsonFile so that we can parse it later on
|
||||
defer jsonFile.Close() |
||||
|
||||
// read our opened xmlFile as a byte array.
|
||||
byteValue, err := ioutil.ReadAll(jsonFile) |
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
|
||||
// we initialize our Users array
|
||||
var data explorer.Data |
||||
|
||||
// we unmarshal our byteArray which contains our
|
||||
// jsonFile's content into 'users' which we defined above
|
||||
err = json.Unmarshal(byteValue, &data) |
||||
if err != nil { |
||||
fmt.Println(err) |
||||
os.Exit(1) |
||||
} |
||||
fmt.Println(data) |
||||
} |
Loading…
Reference in new issue