在Go中解析JSON(无需解组)

I need to parse arbitrary JSON structures in Golang for the sake of translating them into another language format (whether it be C structs or XML), but the Golang library apparently makes this impossible to do with Marshalling and Unmarshalling into structs and maps.

I don't necessarily even need a map-like data structure from the JSON input anyway. All I need is a recursive parser, maybe even something like PHP's XMLParser where you decide what do do yourself at each node, so I can translate it without the need for maps or interfaces.

There is a scanner package in the megajson package that allows you to walk through the json yourself.

scanner := scanner.NewScanner(strings.NewReader(`{"foo":"bar", 
"bat":1293,"truex":true,"falsex":false,"nullx":null,"nested":{"xxx":"yyy"}}`))

// Scan for the next JSON token.
position, token, err := scanner.Scan()