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

STONWriter produces invalid JSON when a string includes single quote characters. #904

Open
gcotelli opened this issue Sep 21, 2023 · 1 comment

Comments

@gcotelli
Copy link

To reproduce evaluate:
STON toJsonString: '''' and you will get "\'" instead of "'".

Something like the following should fix the problem:

STONWriter>>jsonMode: boolean

	jsonMode := boolean.
	jsonMode
		ifTrue: [
			STONCharacters
				at: $' codePoint + 1 put: #pass;
				at: $" codePoint + 1 put: '\"' ]
		ifFalse: [
			STONCharacters
				at: $" codePoint + 1 put: #pass;
				at: $' codePoint + 1 put: '\''' ]

Would be a good idea to add some test cases covering the handling of both single and double quotes for Smalltalk and JSON mode.

@dalehenrich
Copy link
Member

I tried implementing your workaround but some of the existing STONWriterTests JSON tests started failing. I was hoping to include the fix in Rowan masterV2.3.2 for the 3.6.7 release, "at the last minute", but don't have the time (at this moment) to look into a better solution ... should be able to return to this before the end of the year ...

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