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

Empty values in nested JSON #48

Closed
LordEidi opened this issue Aug 16, 2018 · 1 comment
Closed

Empty values in nested JSON #48

LordEidi opened this issue Aug 16, 2018 · 1 comment

Comments

@LordEidi
Copy link

LordEidi commented Aug 16, 2018

I have a very strange bug and am not sure if it is me or what is going wrong.

Take this JSON (I ran it through a validator, looks OK):

{
  "VCALENDAR": {
    "CALSCALE": "GREGORIAN",
    "PRODID": "-//Product.//0.1.0//EN",
    "VERSION": "2.0",
    "VTIMEZONE": {
      "TZID": "Europe/Paris",
      "DAYLIGHT": {
        "DTSTART": "19810329T020000",
        "RRULE": "FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU",
        "TZNAME": "GMT+2",
        "TZOFFSETFROM": "+0100",
        "TZOFFSETTO": "+0200"
      },
      "STANDARD": {
        "DTSTART": "19961027T030000",
        "RRULE": "FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU",
        "TZNAME": "GMT+1",
        "TZOFFSETFROM": "+0200",
        "TZOFFSETTO": "+0100"
      }
    },
    "VEVENT": {
      "CREATED": "20180816T190181Z",
      "LAST-MODIFIED": "20180816T190181Z",
      "DTSTAMP": "20180816T190181Z",
      "DTSTART": "20180816T200000Z",
      "DTEND": "20180816T210000Z",
      "SEQUENCE": "0",
      "SUMMARY": "Demo Event 1534446101813",
      "TRANSP": "OPAQUE",
      "UID": "e972e6c8-77a3-4ef8-9bd1-42ff69593489"
    }
  }
}

When I run that JSON through your gabs.ParseJSON function, I get no error whatsoever, some of the structure, but not all (only one level deep), and I only get the values on the top level.

I get VCALENDAR.VERSION and value of it. I get VCALENDAR.VTIMEZONE.DAYLIGHT, but no value and no sub-level. I get VCALENDAR.VEVENT.CREATED, but not value.

Is there some kind of restriction of depth or something?

@LordEidi
Copy link
Author

I guess I have found the problem(s).

  • GoLand seems to have problems to correctly represent the gabs.Container during debugging. Only showing parts of the tree and values. Not sure why it's like that.
  • If you cast to something like that: gabs.Path("VCALENDAR.VEVENT.DTSTART").Data().(time.Time), you will get a ok = false. Casting to string works. Oh well, I am still trying to get my head around Go sometimes...
  • When you .parseJSON() and then print the resulting gabs.Container with .String(), the order is somewhat different.

The combination of the above was confusing me completely.

Anyway, I fixed my code, sorry for bothering. LFMF.

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

1 participant