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

JSON incompatible value serialization when Emitter has bestWidth #393

Open
hakito opened this issue Mar 20, 2019 · 0 comments
Open

JSON incompatible value serialization when Emitter has bestWidth #393

hakito opened this issue Mar 20, 2019 · 0 comments
Labels

Comments

@hakito
Copy link

hakito commented Mar 20, 2019

When using a JSON compatible value serializer with a Emitter (which has a small bestWidth) the resulting string is no longer JSON compatible because of emitted newlines.

var emitter = new Emitter(someWriter, 2, 5);
var jsonSerializer = new SerializerBuilder().JsonCompatible().BuildValueSerializer();
//...
jsonSerializer.SerializeValue(emitter, "This is a #single# line string", typeof(string));

The hash character causes a double quoted string to be emitted. But because of the bestWidth of 5 in the emitter the string is writton on multiple lines.

Sample output:

key: "This
  is a
  #single#
  line
  string"

As .NET fiddle was not working when writing this I attached a sample code to this message:
JsonBug.cs.txt

@hakito hakito changed the title JSON incampatible value serialization when Emitter has bestWidth JSON incompatible value serialization when Emitter has bestWidth Mar 21, 2019
@aaubry aaubry added the bug label Jun 10, 2019
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

2 participants