Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Decimal type is being serialized as a string #10

Closed
Mitch528 opened this issue Oct 1, 2017 · 3 comments
Closed

Decimal type is being serialized as a string #10

Mitch528 opened this issue Oct 1, 2017 · 3 comments

Comments

@Mitch528
Copy link

Mitch528 commented Oct 1, 2017

public class Foo
{
	public decimal Bar { get; set; }
}

JsonSerializer.ToJsonString(new Foo { Bar = 1.23m }); //outputs { "Bar": "1.23" } - should be { "Bar": 1.23 }

JsonSerializer.Deserialize<Foo>("{\"Bar\":1.23}"); //throws JsonParsingException: expected:", actual:. at:8
neuecc added a commit that referenced this issue Oct 2, 2017
…r, can be deserialize from both string and number #10
@neuecc
Copy link
Owner

neuecc commented Oct 2, 2017

I thought of accuracy, intentionally made it as a string.
But, as you say, Number is good (even for compatibility with JSON.NET etc).

I've changed DecimalFormatter serialize as number.
But can deserialize both string and number format(so not break compatibility).

@neuecc
Copy link
Owner

neuecc commented Oct 2, 2017

I've uploda v1.1.0 it includes this changes.

@Mitch528
Copy link
Author

Mitch528 commented Oct 4, 2017

Alright, great! Thanks.

@Mitch528 Mitch528 closed this as completed Oct 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants