formam icon indicating copy to clipboard operation
formam copied to clipboard

Allow map keys with brackets

Open darigaaz opened this issue 4 years ago • 5 comments

fixed #44

darigaaz avatar Jan 30 '21 17:01 darigaaz

yeah... it looks like complete rewrite of func (dec *Decoder) analyzePath(), that is bad for review,
but i guess i had no other option =\

now it looks more like parsing state machine except formam.go:265

			// found a field, we need to know if the field is next to a closing bracket,
			// if it is then no need to traverse again
			// for example: [0].Field
			if traversedByBracket {
				traversedByBracket = false
				lastPos = i + 1
				continue
			}

where we need to skip traversing if . is following ]
s[k]w == s[k].w (extra dot after closing bracket)

darigaaz avatar Jan 30 '21 17:01 darigaaz

I need to think about this one a bit to ensure there are no edge cases where Weird Stuff™ happens; I'm a bit nervous about that. I need to get back to this.

arp242 avatar Jan 31 '21 08:01 arp242

@arp242 please apply this pr , we want use this lib in our project and need this fix.

stufently avatar Feb 08 '21 10:02 stufently

I haven't had the time to look at it yet @stufently, but you can use replace github.com/monoculum/formam => [..] in your go.mod to use this branch (or any other version) if you want – you don't need to use the master branch.

arp242 avatar Feb 08 '21 11:02 arp242

updated to recent master resolving conflicts

darigaaz avatar Feb 28 '21 14:02 darigaaz