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

Syntax for Objects is inconsistent #2

Open
Philipp-Binder opened this issue Jul 6, 2024 · 0 comments
Open

Syntax for Objects is inconsistent #2

Philipp-Binder opened this issue Jul 6, 2024 · 0 comments

Comments

@Philipp-Binder
Copy link

The Syntax for Objects is inconsistent when having nested objects inside array versus objects nested inside objects.

When parsing object directly, the DotSyntax is used. But if an object lies inside an Enumerable, the objects gets parsed using the BracketSyntax.
There is a proposal-Branch including a test here: https://github.com/Philipp-Binder/csharp-qs/tree/feature/preferDotSyntaxForObjects
The Test fails with the following message when executing on current main:

Expected string to be
"obj.Array[0].NestedObj.Val=innerValue" with a length of 40, but
"obj.Array[0][NestedObj].Val=innerValue" has a length of 41.

Here you see both syntaxes, NestedObj is accessed via Bracket-Syntax ([NestedObj]), while it's values are accessed via Dot-Syntax (.Val)

Looking at NPM qs (https://www.npmjs.com/package/qs?activeTab=readme) does not really help, since it is using brackets everywhere by default.
There is an option to use Dots instead (allowDots), but I'm not sure how it handles Arrays then.
At least it seams to support this scenario.
Either way, objects should use always the same Syntax I think. Actually it would be quite easy now to add an option to switch between Bracket and Dot Syntax for objects.

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

No branches or pull requests

1 participant