Re: [go-nuts] xml to json, parsing xml

2024-04-23 Thread Don Caldwell
Oops, I didn't look carefully at the json output of my little program. It does sometimes emit arrays. For example: go build xmlparse.go ./xmlparse -url 'https://news.google.com/atom' This produces what, for some part, represents acceptable json. The exceptions are the atom entries that would

Re: [go-nuts] generics question

2024-04-23 Thread Ian Lance Taylor
On Mon, Apr 22, 2024 at 11:01 PM Jochen Voss wrote: > > This works, see my code below. Followup question: is there a way to refer to > the new type without having to list both the element type and the pointer > type separately? Unfortunately there is not. At some point in the future the

Re: [go-nuts] xml to json, parsing xml

2024-04-23 Thread Don Caldwell
I agree. The link that I sent demonstrates one very simple way. Mapping XML with repetitive tag sets to JSON arrays, though, would take a bit of work meaning, I think, at least two passes. D On Tue, Apr 23, 2024, 13:04 robert engels wrote: > I don’t think that is true. There are multiple ways

Re: [go-nuts] xml to json, parsing xml

2024-04-23 Thread robert engels
I don’t think that is true. There are multiple ways to model XML into json. See this http://badgerfish.ning.com for one of them. > On Apr 23, 2024, at 11:43 AM, burak serdar wrote: > > In general, you cannot convert xml to json. They have incompatible > models.

Re: [go-nuts] Re: xml to json, parsing xml

2024-04-23 Thread burak serdar
In general, you cannot convert xml to json. They have incompatible models. XML elements are ordered similar to a JSON array, but in many cases you want to map XML elements to JSON objects, which are unordered name-value collections. Also, there is no JSON equivalent of an XML attribute. If you

[go-nuts] Re: xml to json, parsing xml

2024-04-23 Thread Don Caldwell
Disclaimer - I am very new to golang. I puzzled about this for a few days. After some struggle, I got a little program working that parses arbitrary xml into a structure that json can understand. You can find it here: https://github.com/dfwcnj/gxmldecode On Thursday, October 7, 2021 at 10:06:30 

Re: [go-nuts] generics question

2024-04-23 Thread Jochen Voss
Thank you both! This works, see my code below. Followup question: is there a way to refer to the new type without having to list both the element type and the pointer type separately? Below I have to write C[A, *A], which looks slightly ugly. And in my real application something like