Note that there are some explanatory texts on larger screens.

plurals
  1. PODeserialize complex JSON object using ASP.NET?
    text
    copied!<p>I've successfully created code that serializes a complex javascript object and posts it to an ASP.NET page. I can get the JSON string using Request.Form and the result looks like this (I've added indentation for readability):</p> <pre><code> { "gasterPerStolPerVecka": { "name": "gasterPerStolPerVecka", "keyValue_id": "2", "set_id": "1", "containerElement": "#gasterPerStolPerVecka", "keyValueComponents": [ { "name": "gasterPerStolPerVecka_guestsPerWeek", "value": "200" }, { "name": "gasterPerStolPerVecka_numberOfChairs", "value": "100" } ], "keyValueUnitText": "gäster/stol per vecka", "keyValueCalculationMethod": "divide", "isValid": true, "result": 2 }, "tillgangligaStolstimmarPerVecka": { "name": "tillgangligaStolstimmarPerVecka", "keyValue_id": "1", "set_id": "1", "containerElement": "#tillgangligaStolstimmarPerVecka", "keyValueComponents": [ { "name": "tillgangligaStolstimmarPerVecka_openHoursPerWeek", "value": "35" }, { "name": "tillgangligaStolstimmarPerVecka_numberOfChairs", "value": "100" } ], "keyValueUnitText": "stolstimmar/vecka", "keyValueCalculationMethod": "multiply", "isValid": true, "result": 3500 }, "planeradIntaktPerTillgangligStolOchVecka": { "name": "planeradIntaktPerTillgangligStolOchVecka", "keyValue_id": "", "set_id": "", "containerElement": "#planeradIntaktPerTillgangligStolOchVecka", "keyValueComponents": [ { "name": "planeradIntaktPerTillgangligStolOchVecka_weeklyRevenue", "value": "" }, { "name": "planeradIntaktPerTillgangligStolOchVecka_numberOfChairs", "value": "100" } ], "keyValueUnitText": "kr", "keyValueCalculationMethod": "divide", "isValid": false, "result": null, "errorText": "Ofullständigt underlag för beräkning." }, "planeradIntaktPerTillgangligaStolstimmar": { "name": "planeradIntaktPerTillgangligaStolstimmar", "keyValue_id": "", "set_id": "", "containerElement": "#planeradIntaktPerTillgangligaStolstimmar", "keyValueComponents": [ { "name": "planeradIntaktPerTillgangligaStolstimmar_weeklyRevenue", "value": "" }, { "name": "planeradIntaktPerTillgangligaStolstimmar_openHoursPerWeek", "value": "35" }, { "name": "planeradIntaktPerTillgangligaStolstimmar_numberOfChairs", "value": "100" } ], "keyValueUnitText": "kr", "keyValueCalculationMethod": "divide_divide", "isValid": false, "result": null, "errorText": "Ofullständigt underlag för beräkning." } } </code></pre> <p>Now I try to deserialize this on the server side, but it's difficult. I keep getting the error: </p> <p><em>[NullReferenceException: Object reference not set to an instance of an object.]</em></p> <p>I don't know where to start looking for errors?</p> <p>Thanks in advance! /Thomas Kahn</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload