Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't convert this type #4

Closed
magicshui opened this issue Sep 12, 2014 · 3 comments
Closed

can't convert this type #4

magicshui opened this issue Sep 12, 2014 · 3 comments

Comments

@magicshui
Copy link

Our service provider give this kind response,i can't use jsongen to convert it,any suggestions?

{
  "action":"GetMonitorResponse",
  "meter_set":[
    {
      "data":[
        [1392072000,[12,12]],
        [12,12],
        [12,12],
        [11,11],
        [11,11],
        [11,12],
        [15,23],
        [15,29],
        [11,12]
      ],
      "vxnet_id":"vxnet-0",
      "meter_id":"52:54:f4:98:5d:f3",
      "sequence":0
    },
    {
      "data":[
        [1392072000,[0,14440]],
        [0,13762],
        [0,13901],
        [0,14546],
        [0,14710],
        [0,14730],
        [0,14655],
        [0,14898],
        [0,14772]],
      "meter_id":"disk-os"
    },
    {
      "data":[
        [1392072000,7],
        7,
        7,
        7,
        7,
        6,
        7,
        11,
        7
      ],
      "meter_id":"cpu"
    }
  ],
  "ret_code":0,
  "resource_id":"i-1234abcd"}
@bemasher
Copy link
Owner

Looks like it's choking on the data member of the meter_set list. For now you can just convert the data member to a []interface{}. I'll see if I can figure out why JSONGen isn't doing that.

@bemasher
Copy link
Owner

It looks like there isn't any good way to parse the data field. You'll have to use json.RawMessage and do some manual parsing.

@magicshui
Copy link
Author

thanks:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants