Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "encoding/json"
- "fmt"
- )
- type Result struct {
- Data string
- TimeStamp int64
- }
- type ReturnedValue struct {
- Result Result
- Status bool
- }
- func main() {
- data := `
- {
- "result": {
- "data": "A0000",
- "timestamp": 9002
- },
- "status": true
- }
- `
- var retValue ReturnedValue
- if err := json.Unmarshal([]byte(data), &retValue); err != nil {
- panic(err)
- }
- fmt.Println(retValue)
- status := retValue.Status
- fmt.Println("Result:", retValue.Result.Data, ", TS:", retValue.Result.TimeStamp, ", Status:", status)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement