Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Alex Howarth
Could you perhaps achieve this with reflect and UnmarshalJSON() ? The following basic example compares against the case-sensitive json tag: https://play.golang.org/p/Oe_tovxe9Ld On Thu, 23 Sept 2021 at 14:23, 'Aaron' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Hi all > > Anyone kno

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 11:21 +0100, Ian Davis wrote: > This is not a correct interpretation. In your example the > unmarshaller reads the incoming json. The first key encountered is > "Name" and it matches exactly with the field named and tagged as Name > so that field is assigned the value. The ne

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 11:21 +0100, Ian Davis wrote: > This is not a correct interpretation. In your example the > unmarshaller reads the incoming json. The first key encountered is > "Name" and it matches exactly with the field named and tagged as Name > so that field is assigned the value. The ne

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 10:36 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 10:22 +0100, Ian Davis wrote: >> I was responding to your statement that it doesn't appear to use >> exact match in preference. It does, as the example I gave >> demonstrated. It's not about guarding ca

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 10:22 +0100, Ian Davis wrote: > I was responding to your statement that it doesn't appear to use > exact match in preference. It does, as the example I gave > demonstrated. It's not about guarding case. I'll clarify. In the example I posted https://play.golang.org/p/SQyE3R-

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 10:00 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 09:55 +0100, Ian Davis wrote: >> On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts >> wrote: >> > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: >> > > On Friday, 24 September 20

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 09:55 +0100, Ian Davis wrote: > On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts > wrote: > > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: > > > On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler > > > wrote: > > > > The documentation says

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Ian Davis
On Fri, 24 Sep 2021, at 9:36 AM, 'Dan Kortschak' via golang-nuts wrote: > On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: >> On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: >> > The documentation says it prefers exact match over case- >> > insensitive, but example 3 cont

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2021-09-24 at 01:03 -0700, Brian Candler wrote: > On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: > > The documentation says it prefers exact match over case- > > insensitive, but example 3 contradicts that. It seems to be last- > > match that wins. > > > > > > I realis

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Brian Candler
On Friday, 24 September 2021 at 08:25:31 UTC+1 Brian Candler wrote: > The documentation says it > prefers exact match over case-insensitive, but example 3 contradicts that. > It seems to be last-match that wins. > > I realise now what they mean now:

Re: [go-nuts] Parse JSON case-sensitively

2021-09-24 Thread Brian Candler
Wow, I didn't realise until now that Unmarshal does case-insensitive matching: https://play.golang.org/p/wddrcakLvr_Q The documentation says it prefers exact match over case-insensitive, but example 3 contradicts that. It seems to be last-match that

Re: [go-nuts] Parse JSON case-sensitively

2021-09-23 Thread Tyler Compton
Hi Aaron, I'm not aware of a JSON library that fits your needs, but there might be an XY Problem going on here. What problem are you having trouble solving with encoding/json that lead you to this solution? On Thu, Sep 23, 2021 at 11:23 AM 'Aaron' via golang-nuts < golan

[go-nuts] Parse JSON case-sensitively

2021-09-23 Thread 'Aaron' via golang-nuts
Hi all Anyone know of a JSON package (or other solution) which is case-sensitive when decoding - and is also mature, simple, and parses into a struct? I've looked at a few open-source packages, but the ones I've found seem to be focused on performance, or allowing you to access the JSON in diffe