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

Differences between the javascript and C# $append function #29

Open
huangshu91 opened this issue Nov 6, 2024 · 1 comment
Open

Differences between the javascript and C# $append function #29

huangshu91 opened this issue Nov 6, 2024 · 1 comment

Comments

@huangshu91
Copy link

Hi @mikhail-barg, we noticed an interesting discrepancy in the behavior of the $append function.

According to the documentation regarding singleton arrays when a single item is returned the result will be that single value rather than an array. However if a '[]' is used in the expression then we get an array with a single item.

https://docs.jsonata.org/predicate#singleton-array-and-value-equivalence

For example if we look at the try jsonata playground:

https://try.jsonata.org/OmF3X21ZQ

$ ~> | $ | {"test": ([] ~> $append(test))}|

For this simple transform query we get:

{ "test": [ { "test": "test" } ] }

However it seems when we run this same query through the c# implementation we get this:

{"test": { "test": "test"}}

We've worked around this but it seems to be a bug?

@mikhail-barg
Copy link
Owner

hi @huangshu91, thanks for reporting this! I've recently found there seem to be a problem with array constructors in my implementation, that causes some corner cases to behave not in accord with original jsonata-js

For example the behavior addressed here is not yet implemented. The thing you reported seem to have a similar source.

I've made a first attempt to address this issue, but the problem seem to be more deep than I've expected, and fixing it will probably require a lot of careful tunings. So I'll need some time to muster enough courage to make a second attempt.

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

2 participants