asp.net web api dynamic json
I have a web api endpoint that receives JSON and serializes it into
objects. Very basic and common stuff. However, I have a requirement to
accept custom user defined fields. For example, a developer may want to
add a custom field for "account #" and pass that along via the API. I'm
stuck how I could define a field on my class if I don't know the name. I
need to support unlimited fields so I cannot simply create a field for
custom1, custom2, custom2, etc.
I would think that my JSON could look something like this... where
custom_label_xxx is identifies the field label:
...
"custom_fields": {
"custom_label_90": 49,
"custom_label_83": [ 28, 29, 30 ],
"custom_label_89": "2012/05/21"
},
...
How in the world can I setup a dynamic class to accept this dynamic JSON?
I have Googled forever and cannot find any examples using custom fields.
No comments:
Post a Comment