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

INDENT_OUTPUT for ION format? #337

Open
didibus opened this issue Aug 30, 2022 · 4 comments
Open

INDENT_OUTPUT for ION format? #337

didibus opened this issue Aug 30, 2022 · 4 comments
Labels

Comments

@didibus
Copy link

didibus commented Aug 30, 2022

IonObjectMapper om = new IonObjectMapper();
om.enable(SerializationFeature.INDENT_OUTPUT);
om.writeValueAsString(object)

Doesn't seem to work with an IonObjectMapper the way it does with the JSON ObjectMapper, any way to accomplish the same?

@cowtowncoder
Copy link
Member

Ion backend would need to support this. I think Ion textual format does have the functionality.
Did you test with latest (2.13.3) version?

@mcliedtke
Copy link
Contributor

Ion backend does support "pretty printing" Ion text, they have some documentation on it here - https://amzn.github.io/ion-docs/guides/cookbook.html#pretty-printing.

It might be down to customizing the IonWriter being used to produce the Text output based on the feature flag.

In the meantime, you could be unblocked by using IonObjectMapper.writeValueAsIonValue to output to an IonValue and then pretty-print that value using the IonWriter methods referenced in the link

@cowtowncoder
Copy link
Member

Thank you @mcliedtke!

It sounds like this feature could well be implemented by someone with time on their hands.
In the meantime I think IonMapper might have additional writeValue() methods that could take properly initialized IonWriter (not 100% sure as I didn't check but I think it does have some extensions to main ObjectMapper API).

@didibus
Copy link
Author

didibus commented Aug 30, 2022

In the meantime, you could be unblocked by using IonObjectMapper.writeValueAsIonValue to output to an IonValue and then pretty-print that value using the IonWriter methods referenced in the link

I did this for now, and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants