asp.net mvc - Draw2d C# MVC Post JSON to Controller -


i working draw2d library allows exporting of json when try cannot export mvc. not issue draw2d rather lack of knowledge me how work. generate json looks below

    [     {         "type": "dbtable",         "id": "662b1fb8-5eb8-47a5-9f81-e48efb0d31bd",         "x": 80,         "y": 59,         "width": 99,         "height": 107,         "cssclass": "dbtable",         "bgcolor": "#dbddde",         "color": "#d7d7d7",         "stroke": 1,         "alpha": 1,         "radius": 3,         "name": "default autoattendant",         "entities": [             {                 "text": "0",                 "id": "0c4c5414-1f35-4247-a4b7-38297aa0e5ff"             },             {                 "text": "1",                 "id": "706e1cb7-a9d1-461d-8230-0bf136c1d850"             }         ]     },     {         "type": "nameduser",         "name": "scott",         "id": "0d2c71cf-52ee-4c50-a974-ea07003df05e",         "cssclass": "nameduser",         "bgcolor": "#dbddde",         "color": "#d7d7d7",         "stroke": 1,         "alpha": 1,         "radius": 3,         "x": 220,         "y": 200     },     {         "type": "nameduser",         "name": "nancy",         "id": "601b0ad9-a0e9-4604-8861-38694a43e0a8",         "cssclass": "nameduser",         "bgcolor": "#dbddde",         "color": "#d7d7d7",         "stroke": 1,         "alpha": 1,         "radius": 3,         "x": 220,         "y": 200     } ] 

my controller basic @ moment weed out potential side effect issues.,

public actionresult draw2dretrievejson(alljson alljsontxt)     { 

my class looks this

public class alljson {    public  ienumerable<hostedvoiceuserjson> hostedvoiceuserjson { get; set; }    //public ienumerable<hostedvoicehuntgroupjson> hostedvoicehuntgroupjson { get; set; }    //public ienumerable<hostedvoiceaajson> hostedvoiceaajson { get; set; }    //public ienumerable<hostedvoiceconnectionjson> hostedvoiceconnectionjson { get; set; } } 

i followed post got me far getting "nameduser" objects post , me manually changing json string match

{                 "hostedvoiceuserjson": [                     {                         "type": "nameduser",                         "name": "scott",                         "id": "0d2c71cf-52ee-4c50-a974-ea07003df05e",                         "cssclass": "nameduser",                         "bgcolor": "#dbddde",                         "color": "#d7d7d7",                         "stroke": 1,                         "alpha": 1,                         "radius": 3,                         "x": 220,                         "y": 200                     },                     {                         "type": "nameduser",                         "name": "nancy",                         "id": "601b0ad9-a0e9-4604-8861-38694a43e0a8",                         "cssclass": "nameduser",                         "bgcolor": "#dbddde",                         "color": "#d7d7d7",                         "stroke": 1,                         "alpha": 1,                         "radius": 3,                         "x": 220,                         "y": 200                     }                 ]             } 

of course cannot sit here , manually change these time need able find away work can post multiple different types together.

it looks json array of objects. need homogeneus json collections in order recognized automatically modelbinder.

based on type, separate json objects , send them in different, homogeneous arrays. way match model class in c#


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -