Kees C. Bakker
Kees C. Bakker

Reputation: 33411

Is JSON.Net guaranteed to always serialize the same way?

I need to generate a 'string' key based on the state of an object. I thought of serializing the object to JSON and use the result as key. This only works if JSON.Net always serializes the same way.

Is JSON.Net guaranteed to serialize the same way on the same machine if an object of the same class with the same state if encountered?

Upvotes: 3

Views: 227

Answers (1)

James Newton-King
James Newton-King

Reputation: 49052

Yes, otherwise the unit tests would fail.

There is an Order property on JsonPropertyAttribute if you want to explicitly state the order.

Upvotes: 4

Related Questions