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

Allow map keys with brackets #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

darigaaz
Copy link
Contributor

fixed #44

@darigaaz
Copy link
Contributor Author

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)

// 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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@darigaaz darigaaz mentioned this pull request Jan 30, 2021
@arp242
Copy link
Collaborator

arp242 commented Jan 31, 2021

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.

@stufently
Copy link

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

@arp242
Copy link
Collaborator

arp242 commented Feb 8, 2021

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.

@darigaaz darigaaz force-pushed the allow_map_keys_with_brackets branch from 9527da5 to 7600225 Compare February 28, 2021 14:47
@darigaaz
Copy link
Contributor Author

updated to recent master resolving conflicts

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

Successfully merging this pull request may close these issues.

Allow map keys with brackets
3 participants