You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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:
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.
The text was updated successfully, but these errors were encountered: