Odd dynamic effect with JObject #3641
jamescurran
started this conversation in
NA
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Source/destination types
Gist: https://gist.github.com/jamescurran/fb13fa7563edf8d9e96cf04aab723f99
Mapping configuration
Version: 13.0.1
Expected behavior
A | 888
Bbb | 999
C | Greetings
D | 789
The value for properties
A
,Bbb
, andC
are changed, and the non-matching fieldD
is unchanged.Actual behavior
We get the expected behavior when using ExpandoObject. However, if we use JObject (which is what JSON.NET will give you if you deserialize to a
dynamic
, we get the following:A | 123
Bbb | 456
C | Greetings
D | 0
The
int
properties are not changed, the string property is changed, and the non-matching fieldD
set to zero.Steps to reproduce
Real-world scenario which led to this
SPA app for editing a user record. The update is made through a webservice API that receives a JSON object with just the changed fields, so object structure changes on every call, so it must be received as a
dynamic
.When using JSON.NET that dynamic object is actually a
JObject
Workaround (for my situation)
Force use of
ExpandoObject
Beta Was this translation helpful? Give feedback.
All reactions