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

Allow serialization with Single Quotes \' in stead of Standard Double Quotes \" #617

Closed
anismek opened this issue May 14, 2020 · 12 comments
Closed
Labels
good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project hacktoberfest Issue related to Hactoberfest2020 activities, eligible for additional rewards

Comments

@anismek
Copy link

anismek commented May 14, 2020

Adding something like this feature JsonWriteFeature.USE_SINGLE_QUOTE. Permitting to serialize:
{"name": "value"} to {'name': 'value'} and if also JsonWriteFeature.QUOTE_FIELD_NAMES is disabled to {name: 'value'}.
I know this is not standard JSON, but might be really helpful to get TypeScript-formatted JSON.

@cowtowncoder
Copy link
Member

There is a PR already for this (see #235) but I think I can move this as an RFE for jackson-core to match.

@anismek
Copy link
Author

anismek commented May 15, 2020

@cowtowncoder thanks !

@srgg
Copy link

srgg commented Jul 29, 2020

Any chance to get this merged into the base line?

@cowtowncoder
Copy link
Member

I am hoping to get this merged to be included in 2.12.0, but unfortunately there is lots of work and this is not one of priority items.

@srgg
Copy link

srgg commented Jul 29, 2020

@cowtowncoder np, thank you for your work

@cowtowncoder
Copy link
Member

Thank you! Let's hope it makes it in -- it is included on my long todo list:

https://github.com/FasterXML/jackson-future-ideas/wiki/Jackson-Work-in-Progress

@cowtowncoder cowtowncoder added good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project hacktoberfest Issue related to Hactoberfest2020 activities, eligible for additional rewards labels Oct 9, 2020
@harsh201
Copy link

@cowtowncoder I am new here and would like to pick this one.

@cowtowncoder
Copy link
Member

@harsh201 excellent! Make sure to start with 2.12 branch. Also PR #235 is pretty good; I'd make only couple of small changes.

@angelyan
Copy link

@cowtowncoder is this not possible already in 2.12 with new JsonFactoryBuilder().quoteChar('\'').build()?

@cowtowncoder
Copy link
Member

cowtowncoder commented Oct 21, 2020

@angelyan ... and you are absolutely right, it is.

Sometimes I surprise myself by rediscovering something I already implemented... and not all that long ago. :-D

Issue was #549 and is a superset: can use apostrophe or any other ASCII character (if that was necessary).

@angelyan
Copy link

@cowtowncoder I think there's something missing, though. Shouldn't singles quotes be escaped and double quotes be left as is here?

assertEquals("{'key':'It\\u0027s \\\"fun\\\"'}", w.toString());

@cowtowncoder
Copy link
Member

cowtowncoder commented Oct 21, 2020

I am sure there are different preferences; some might prefer minimal escaping, others keeping both.
It probably seemed safer not to assume that double-quotes should be kept quoted.

If there is some follow-up improvements needed, filing a new issue is always possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project hacktoberfest Issue related to Hactoberfest2020 activities, eligible for additional rewards
Projects
None yet
Development

No branches or pull requests

5 participants