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

Option to have single line or indented string as output from Eval #27

Open
mikanygTC opened this issue Jun 19, 2024 · 2 comments
Open

Comments

@mikanygTC
Copy link

In the current implementation of JsonataQuery.Eval(string) the result is always indented and formatted.

I suggest a minor change either as optional parameter or overload, to specify if output string is indented or single line.

When moving json over the network wire, a compact format can often be a better choice.

@mikhail-barg
Copy link
Owner

mikhail-barg commented Jun 19, 2024

Hi, @mikanygTC thank you for the proposal.

Still I'm not sure how to include it in a library. Adding an optional argument to existing method would break binary compatibility. And adding an override looks like an overkill.

If you find it useful, you may implement an extension in your code, using same code and JToken.ToFlatString() instead of JToken.ToIndentedString()

@mikanygTC
Copy link
Author

Well an extension method would work and did something like this to get the behavoir. Suggested this change so others could benefit from it.

I understand that optional parameter is a breaking change, and would be the less ideal approach to include it in the lib. If the library would offer the choice for consumers to specify the preferred output formatting, I don't see the overload of the Eval method as being overkill, but maybe I'm missing some insights.

I'll go with the extension method, but still suggest to have some option to specify output format directly included in the library.

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