You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the object is converted to a JSON string, it appears that when the object gets converted into a JToken, the JValue._valueType is converted to an enum such as JTokenType.Guid or JTokenType.TimeSpan, but if you convert a string to a JObject, the values will be brought in as a string for the following types (these are the ones I found in my ad hock testing. there may be more):
JTokenType.Guid
JTokenType.Date
JTokenType.TimeSpan
This can cause issues when you are trying to convert a JSON string into a comparable type to compare with a native object that you cannot edit.
As for workarounds, there are not any to my knowledge (except to convert it to a native type and check that way, or implement a custom value checker).
Proposed solution (only affects the JValue class):
Add a new configuration option for the comparison that allows for a "lazy type check" to ignore the JValue._valueType variable.
convert both values to a string
do a string comparison instead of an object value check.
(affects everywhere else):
The value would have to be passed down through multiple classes:
When the object is converted to a JSON string, it appears that when the object gets converted into a JToken, the
JValue._valueType
is converted to an enum such asJTokenType.Guid
orJTokenType.TimeSpan
, but if you convert a string to a JObject, the values will be brought in as a string for the following types (these are the ones I found in my ad hock testing. there may be more):JTokenType.Guid
JTokenType.Date
JTokenType.TimeSpan
This can cause issues when you are trying to convert a JSON string into a comparable type to compare with a native object that you cannot edit.
As for workarounds, there are not any to my knowledge (except to convert it to a native type and check that way, or implement a custom value checker).
Proposed solution (only affects the JValue class):
JValue._valueType
variable.(affects everywhere else):
JArray.DeepEquals
JConstructor.DeepEquals
JObject.DeepEquals
JProperty.DeepEquals
JToken.DeepEquals
(both sets of functions)JTokenEqualityComparer.Equals
JValue.DeepEquals
Code Example:
The text was updated successfully, but these errors were encountered: