Getting Newtonsoft.Json.JsonSerializationException error when deserializing a Json object - json

I'm having an issue when trying to send Docusign envelope with custom recipient mail (using recipientMailNotification) trough its API service. My controller receives the request properly, but before it sends to docusign service it deserializes into an object, and that's when the error occurs.
**JSON Request:**
"Recipients": [{
"Order": 1,
"Name": "Andre Test ",
"Email": "andre#test.com",
"SignerType": "SIGNER",
"DocusignSignerType": 0,
"SignatureType": "ELECTRONIC",
"EtapaFinalizada": false,
"EmailNotification":{
"emailBody": "SIGN AS SIGNER",
"emailSubject": "SIGNER SIGNATURE REQUIRED"
}
},
{
"Order": 2,
"Name": "Luis Teste",
"Email": "luis#test.com",
"SignerType": "WITNESS",
"DocusignSignerType": 0,
"SignatureType": "ELECTRONIC",
"EtapaFinalizada": false,
"EmailNotification": {
"emailBody": "SIGN AS WITNESS",
"emailSubject": "WITNESS SIGNATURE REQUIRED"
}
}
]
Gives me the error:
'Cannot deserialize the current JSON object
(e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[eSignature.
Providers.Docusign.Entities.RecipientEmailNotification]'
I'm not using a list<> or array of any type. is just a standard property nested inside another.
Tried the solution listed here but still getting the error.
Using Json2CSharp gives me same structure as my current class so I assume it is correct Json.
EDIT: Please note that I'm not even expeting an array or List on my class property:
public class Destinatario
{
public int Order { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public string SignerType{ get; set; }
public int DocusignSignerType{ get; set; }
public string SignatureType{ get; set; }
public bool EtapaFinalizada { get; set; }
public RecipientEmailNotification EmailNotification { get; set; }
}

Recipients JSON looks like this:
"recipients": {
"signers": [{
"email": "test1#email.com",
"name": "Name 1",
"recipientId": "1",
"routingOrder": "1",
"tabs": {
"signHereTabs": *[{
"xPosition": "100",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}]
}
},
{
"email": "test2#email.com",
"name": "Name 2",
"recipientId": "2",
"routingOrder": "2",
"tabs": {
"initialHereTabs": *[{
"xPosition": "100",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1"
}],
"signHereTabs": [*{
"xPosition": "200",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1"
}]
}
}
],
"carbonCopies": [{
"email": "test3#email.com",
"name": "Name 3",
"recipientId": "3",
"routingOrder": "3"
},
{
"email": "test*4#email.com",
"name": "Name 4",
"recipientId": "4",
"routingOrder": "3"
}
]
}
You do not have it separated into different kinds of recipients so your JSON is invalid.
Please see https://developers.docusign.com/esign-rest-api/guides/features/recipients for more information.

Related

deserialize conplex json and access property in xamarin

hello everyone i am fetching some json data from server and i want to desalinize that complex json and add in custom object and i dont know how to access that property value .
Here is the json data format
[
{
"Id": 1,
"AlbumId": 2,
"Name": "sample string 3",
"Url": "sample string 4",
"ShareUrl": "sample string 5",
"Selected": true,
"Comment": "sample string 6",
"Album": {
"Id": 1,
"Name": "sample string 2",
"PhotoGrapherId": 3,
"ClientId": 4,
"EventType": "sample string 5",
"EventDate": "2017-10-11T12:06:33.735998+05:30",
"Status": "sample string 7",
"Url": "sample string 8",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 10",
"Client": {
"Id": 1,
"Name": "sample string 2",
"ContactPersonName": "sample string 3",
"ContactPersonMobile": "sample string 4",
"ContactPersonEmail": "sample string 5",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 7",
"Albums": []
},
"PhotoGrapher": {
"Id": 1,
"Name": "sample string 2",
"ContactPersonName": "sample string 3",
"ContactPersonMobile": "sample string 4",
"ContactPersonEmail": "sample string 5",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 7",
"Albums": []
},
"Photos": []
}
},
{
"Id": 1,
"AlbumId": 2,
"Name": "sample string 3",
"Url": "sample string 4",
"ShareUrl": "sample string 5",
"Selected": true,
"Comment": "sample string 6",
"Album": {
"Id": 1,
"Name": "sample string 2",
"PhotoGrapherId": 3,
"ClientId": 4,
"EventType": "sample string 5",
"EventDate": "2017-10-11T12:06:33.735998+05:30",
"Status": "sample string 7",
"Url": "sample string 8",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 10",
"Client": {
"Id": 1,
"Name": "sample string 2",
"ContactPersonName": "sample string 3",
"ContactPersonMobile": "sample string 4",
"ContactPersonEmail": "sample string 5",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 7",
"Albums": []
},
"PhotoGrapher": {
"Id": 1,
"Name": "sample string 2",
"ContactPersonName": "sample string 3",
"ContactPersonMobile": "sample string 4",
"ContactPersonEmail": "sample string 5",
"CreatedOn": "2017-10-11T12:06:33.735998+05:30",
"CreatedBy": "sample string 7",
"Albums": []
},
"Photos": []
}
}
]
I want to deserialize that json data in my cutom object and access each property dynamically.
i tried as follow
PhotoJson myListObj = JsonConvert.DeserializeObject<PhotoJson>(responseText, settings);
and PhotoJson.cs
class PhotoJson
{
public string Id { get; set; }
public string AlbumId { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string ShareUrl { get; set; }
public string Selected { get; set; }
public string Comment { get; set; }
}
Please any help me get it sort out my problem.i am not getting ore help on net also.
Actually the Json is usually a List of your class object
Using the following would do the trick
List<PhotoJson> myListObj = JsonConvert.DeserializeObject<PhotoJson>(responseText, settings);
or
var myListObj = JsonConvert.DeserializeObject<PhotoJson>(responseText, settings);
And then Simply using Linq to get the specific data would do the trick.
And i'm pretty sure the model class you have created is not proper you should update it as per the what Json is returning or else things wont work properly

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'WindowsApplication1.Helpers+SalePayment[]'

Please HELP!!!!
I am trying to deserialize a Json. The problem I have is when I have just 1 "SalePayment"(Since this is not coming as array). If I have several "SalePayment" like in the example json then my code works fine.
This is the json
{
"#attributes": {
"count": "1",
"offset": "0",
"limit": "100"
},
"Sale": {
"saleID": "55",
"timeStamp": "2016-06-11T13:08:16+00:00",
"discountPercent": "0",
"completed": "true",
"archived": "false",
"voided": "false",
"enablePromotions": "true",
"isTaxInclusive": "false",
"referenceNumber": "",
"referenceNumberSource": "",
"tax1Rate": "0",
"tax2Rate": "0",
"change": "0",
"receiptPreference": "printed",
"displayableSubtotal": "2700",
"ticketNumber": "220000000055",
"calcDiscount": "0",
"calcTotal": "2700",
"calcSubtotal": "2700",
"calcTaxable": "0",
"calcNonTaxable": "2700",
"calcAvgCost": "0",
"calcFIFOCost": "0",
"calcTax1": "0",
"calcTax2": "0",
"calcPayments": "2700",
"total": "2700",
"totalDue": "2700",
"displayableTotal": "2700",
"balance": "0",
"customerID": "0",
"discountID": "0",
"employeeID": "1",
"quoteID": "0",
"registerID": "1",
"shipToID": "0",
"shopID": "1",
"taxCategoryID": "0",
"SalePayments": {
"SalePayment": [
{
"salePaymentID": "40",
"amount": "500",
"createTime": "2016-06-11T13:08:16+00:00",
"archived": "false",
"remoteReference": "",
"paymentID": "",
"saleID": "55",
"paymentTypeID": "2",
"ccChargeID": "0",
"refPaymentID": "0",
"registerID": "1",
"employeeID": "1",
"creditAccountID": "0",
"PaymentType": {
"paymentTypeID": "2",
"name": "Check",
"requireCustomer": "false",
"archived": "false",
"internalReserved": "false",
"type": "user defined",
"refundAsPaymentTypeID": "0"
}
},
{
"salePaymentID": "41",
"amount": "500",
"createTime": "2016-06-11T13:08:16+00:00",
"archived": "false",
"remoteReference": "",
"paymentID": "",
"saleID": "55",
"paymentTypeID": "3",
"ccChargeID": "0",
"refPaymentID": "0",
"registerID": "1",
"employeeID": "1",
"creditAccountID": "0",
"PaymentType": {
"paymentTypeID": "3",
"name": "Credit Card",
"requireCustomer": "false",
"archived": "false",
"internalReserved": "false",
"type": "user defined",
"refundAsPaymentTypeID": "0"
}
},
{
"salePaymentID": "42",
"amount": "1300",
"createTime": "2016-06-11T13:08:16+00:00",
"archived": "false",
"remoteReference": "",
"paymentID": "",
"saleID": "55",
"paymentTypeID": "6",
"ccChargeID": "0",
"refPaymentID": "0",
"registerID": "1",
"employeeID": "1",
"creditAccountID": "0",
"PaymentType": {
"paymentTypeID": "6",
"name": "Debit Card",
"requireCustomer": "false",
"archived": "false",
"internalReserved": "false",
"type": "user defined",
"refundAsPaymentTypeID": "0"
}
},
{
"salePaymentID": "43",
"amount": "400",
"createTime": "2016-06-11T13:08:16+00:00",
"archived": "false",
"remoteReference": "",
"paymentID": "",
"saleID": "55",
"paymentTypeID": "1",
"ccChargeID": "0",
"refPaymentID": "0",
"registerID": "1",
"employeeID": "1",
"creditAccountID": "0",
"PaymentType": {
"paymentTypeID": "1",
"name": "Cash",
"requireCustomer": "false",
"archived": "false",
"internalReserved": "true",
"type": "cash",
"refundAsPaymentTypeID": "0"
}
}
]
},
"taxTotal": "0"
}
}
This is the CLASS
Public Class Helpers
Public Property attribute As Attributes
Public Property Sale As Sales
Public Class Attributes
Public Property count As String
Public Property offset As String
Public Property limit As String
End Class
Public Class PaymentType
Public Property paymentTypeID As String
Public Property name As String
Public Property requireCustomer As String
Public Property archived As String
Public Property internalReserved As String
Public Property type As String
Public Property refundAsPaymentTypeID As String
End Class
Public Class SalePayment
Public Property salePaymentID As String
Public Property amount As String
Public Property createTime As DateTime
Public Property archived As String
Public Property remoteReference As String
Public Property paymentID As String
Public Property saleID As String
Public Property paymentTypeID As String
Public Property ccChargeID As String
Public Property refPaymentID As String
Public Property registerID As String
Public Property employeeID As String
Public Property creditAccountID As String
Public Property PaymentType As PaymentType
End Class
Public Class SalePayments
Public Property SalePayment As SalePayment()
End Class
Public Class Sales
Public Property saleID As String
Public Property timeStamp As DateTime
Public Property discountPercent As String
Public Property completed As String
Public Property archived As String
Public Property voided As String
Public Property enablePromotions As String
Public Property isTaxInclusive As String
Public Property referenceNumber As String
Public Property referenceNumberSource As String
Public Property tax1Rate As String
Public Property tax2Rate As String
Public Property change As String
Public Property receiptPreference As String
Public Property displayableSubtotal As String
Public Property ticketNumber As String
Public Property calcDiscount As String
Public Property calcTotal As String
Public Property calcSubtotal As String
Public Property calcTaxable As String
Public Property calcNonTaxable As String
Public Property calcAvgCost As String
Public Property calcFIFOCost As String
Public Property calcTax1 As String
Public Property calcTax2 As String
Public Property calcPayments As String
Public Property total As String
Public Property totalDue As String
Public Property displayableTotal As String
Public Property balance As String
Public Property customerID As String
Public Property discountID As String
Public Property employeeID As String
Public Property quoteID As String
Public Property registerID As String
Public Property shipToID As String
Public Property shopID As String
Public Property taxCategoryID As String
Public Property SalePayments As SalePayments
Public Property taxTotal As String
End Class
End Class
And this is the code
Dim OrdersSaleList As Helpers
OrdersSaleList = JsonConvert.DeserializeObject(Of Helpers)(json)
I am getting this error
Cannot deserialize the current JSON object (e.g. {"name":"value"})
into type 'WindowsApplication1.Helpers+SalePayment[]' because the type
requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix
this error either change the JSON to a JSON array (e.g. [1,2,3]) or
change the deserialized type so that it is a normal .NET type (e.g.
not a primitive type like integer, not a collection type like an array
or List) that can be deserialized from a JSON object.
JsonObjectAttribute can also be added to the type to force it to
deserialize from a JSON object. Path
'Sale.SalePayments.SalePayment.salePaymentID', line 1, position 3821.

JSON request to ASP.NET API

I have the following JSON Data:
{
"0": {
"id": 0,
"type": "camera",
"option": [
{
"optionId": 1,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
}
]
},
"1": {
"id": 1,
"type": "checkCategory",
"option": [
{
"optionId": 1,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
},
{
"optionId": 2,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
}
]
}
}
How to pass JSON data into ASP.NET API request with which type of parameter in controller action?
Asp.net MVC automap and try to cast each key:value of json.
{"key1":"value", "key2":"value"}
You can access those values using params inside your function
public ActionResult Index(string key,string key2)
Or creating a class with public setter equal to your keys and a parameterless constructor.
public Class MyJson
{
public string key1 {get;set;}
public string key2 {get;set;}
}
public ActionResult Index(MyJson model)
In your specific case your passing a List of Object so you should use
public ActionResult Index(List<MyJson> model)
If you change your json to:
[
{
"id": 0,
"type": "camera",
"option": [
{
"optionId": 1,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
}
]
},
{
"id": 1,
"type": "checkCategory",
"option": [
{
"optionId": 1,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
},
{
"optionId": 2,
"optionValue": "",
"answered": "false",
"lastanswerd": "false"
}
]
}
]
json2csharp gives us:
public class Option
{
public int optionId { get; set; }
public string optionValue { get; set; }
public string answered { get; set; }
public string lastanswerd { get; set; }
}
public class RootObject
{
public int id { get; set; }
public string type { get; set; }
public List<Option> option { get; set; }
}

List<Object> serialization not working with multiple objects

I have the following classes
[DataContract]
public class Video
{
[Key]
[DataMember(IsRequired = false)]
public int VideoId { get; set; }
[DataMember(IsRequired = false)]
public int UserId { get; set; }
[Required]
[DataMember ]
public string Title { get; set; }
[Required]
[DataMember]
public virtual IList<Tag> Tags { get; set; }
}
[DataContract]
public class Tag
{
[Key]
[Required]
[DataMember(IsRequired = false)]
public int? TagId { get; set; }
[DataMember(IsRequired = true)]
[Required]
public string Name { get; set; }
[IgnoreDataMember]
public virtual IList<Video> Videos { get; set; }
}
In my WebAPI controller, I call this:
var videos = _service.GetVideos();
return Request.CreateResponse(HttpStatusCode.OK, videos);
Which calls this:
public IList<Video> GetVideos()
{
using (var db = CreateContext())
{
return db.Videos.Include("Tags").ToList();
}
}
Yet over the wire, this is what I get:
[{
"$id": "8",
"tags": [
{
// CORRECT SERIALIZATION
"$id": "9",
"tagId": 1,
"name": "Example",
"count": 5
}
],
"videoId": 18,
"userId": 3,
"title": "Test Video",
"thumbnail": "http://i.imgur.com/gV3J2Uf.png",
"source": "test source"
},
{
"$id": "19",
"tags": [
{
// WTF?
"$ref": "9"
}
],
"videoId": 28,
"userId": 6,
"title": "Test Video",
"thumbnail": "http://i.imgur.com/gV3J2Uf.png",
"source": "test source"
},
{
"$id": "20",
"tags": [
{
// CORRECT AGAIN
"$id": "21",
"tagId": 10,
"name": "funny",
"count": 2
}
],
"videoId": 29,
"userId": 6,
"title": "TEST VID",
"thumbnail": "https://i.imgur.com/SWOQSOf.jpg",
"source": "test source"
},
{
"$id": "22",
"tags": [
{
// INCORRECT
"$ref": "9"
},
{
"$ref": "21"
}
],
"videoId": 30,
"userId": 6,
"title": "TEST VID",
"thumbnail": "https://i.imgur.com/R7lVobX.jpg",
"source": "test source"
}
For some reason - tags is sometimes serializing correctly, and sometimes not. Any idea what I'm doing wrong?
You have circular references in your object graph. They cannot be JSON serialized properly, the serializer detects this condition and automatically makes references ($ref). when you are loading the object graph using EF there are circular references between those objects in memory which cannot be represented correctly in JSON.
I would recommend you breaking the circular references graph by using a view model and then sending the view model over the wire instead of directly returning your autogenerated EF models.

Deserializing JSON using JSon.NET with dynamic data

I'm trying to deserialize some JSON data into objects for an application. Up until now it's been fine because the properties on the JSON data was static (key with a value). Now I've got a result where the key is a dynamic piece of data.
Here's an example JSON url:
http://en.wikipedia.org/w/api.php?action=query&format=json&pageids=6695&prop=info
The resulting JSON for this is:
{ "query" : { "pages" : { "6695" : { "counter" : "",
"lastrevid" : 468683764,
"length" : 8899,
"ns" : 0,
"pageid" : 6695,
"title" : "Citadel",
"touched" : "2012-01-03T19:16:16Z"
} } } }
Okay, that's great except I can't deserialize the "pages" data into an object. If I were to define a class for the pages it would have to look like this:
public class 6695
{
public string counter { get; set; }
public int lastrevid { get; set; }
public int length { get; set; }
public int ns { get; set; }
public int pageid { get; set; }
public string title { get; set; }
public string touched { get; set; }
}
In order to deserialze the contents (using JsonConvert.Deserialize(jsondata)) and we all know we can't have a class called 6695. Not only that, the name of the class would have to be different (for example pageid=7145 would have to be the 7145 class).
I can seem to pluck some values out if I use something like JObject.Parse(content) and then access items as JArrays but it's pretty ugly and I'm still stuck on trying to get out the data from the pages array.
Looking for someone to help with this. I don't think it's uncommon, it's just not JSON data I've come across before and not sure how to handle it.
Thanks!
PS forgot to mention this is on Windows Phone 7 so "dynamic" isn't available!
The simplest method. In this particular case would probably be to go dynamic.
dynamic data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(json);
var lastRevId = data.query.pages["6695"].lastrevid;
You can reference any element by it's [] name so you can do something like data["query"]["pages"]["6695"]["lastrevid"]. This will get by all those little objects where the name isn't valid in c#.
Here is how you do using https://github.com/facebook-csharp-sdk/simple-json ( https://nuget.org/packages/SimpleJson ).
var text = "{\"query\":{\"pages\":{\"6695\":{\"pageid\":6695,\"ns\":0,\"title\":\"Citadel\",\"touched\":\"2012-01-03T19:16:16Z\",\"lastrevid\":468683764,\"counter\":\"\",\"length\":8899}}}}";
(Using dynamic)
dynamic json = SimpleJson.DeserializeObject(text);
string title = json.query.pages["6695"].title;
foreach (KeyValuePair<string, dynamic> page in json.query.pages)
{
var id = page.Key;
var pageId = page.Value.pageid;
var ns = page.Value.ns;
}
(Using strongly typed classes)
class result
{
public query query { get; set; }
}
class query
{
public IDictionary<string, page> pages { get; set; }
}
class page
{
public long pageid { get; set; }
public string title { get; set; }
}
var result = SimpleJson.DeserializeObject<result>(text);
[Update]
on windows phone where dynamic is not supported and you don't want to use strongly typed classes.
var json = (IDictionary<string, object>)SimpleJson.DeserializeObject(text);
var query = (IDictionary<string, object>)json["query"];
var pages = (IDictionary<string, object>)query["pages"];
var pageKeys = pages.Keys;
var page = (IDictionary<string, object>)pages["6695"];
var title = (string)page["title"];
I hope the below example will help.
I always design a model that match the json. It is much better to work with the object when it is your own model design.
It is very easy to generate the c# model from the json. I use this website to generate the model: http://json2csharp.com
A complete example is:
C# Code:
var targetsObject = Newtonsoft.Json.JsonConvert.DeserializeObject<YourModel>(jsonString);
JSON:
{
"investors": [
{
"name": "06",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": "5.5"
},
{
"name": "VA IRRRL",
"value": "6.0"
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "07",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": "7.0"
},
{
"name": "VA",
"value": "5.5"
},
{
"name": "VA IRRRL",
"value": ""
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "08",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": "7.0"
},
{
"name": "VA",
"value": "5.5"
},
{
"name": "VA IRRRL",
"value": ""
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "09",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": "5.5"
},
{
"name": "VA IRRRL",
"value": ""
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "10",
"programs": [
{
"name": "Conventional",
"value": ""
},
{
"name": "FHA - Standard",
"value": ""
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": ""
},
{
"name": "VA IRRRL",
"value": ""
},
{
"name": "Non-Prime",
"value": "2.0"
}
]
},
{
"name": "11",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": "6.0"
},
{
"name": "VA IRRRL",
"value": "6.0"
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "12",
"programs": [
{
"name": "Conventional",
"value": "3.5"
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": "5.5"
},
{
"name": "VA IRRRL",
"value": "6.0"
},
{
"name": "Non-Prime",
"value": ""
}
]
},
{
"name": "13",
"programs": [
{
"name": "Conventional",
"value": ""
},
{
"name": "FHA - Standard",
"value": "5.0"
},
{
"name": "FHA - Streamline",
"value": ""
},
{
"name": "VA",
"value": ""
},
{
"name": "VA IRRRL",
"value": ""
},
{
"name": "Non-Prime",
"value": "2.0"
}
]
}
]
}
Model:
public class Program
{
public string name { get; set; }
public string value { get; set; }
}
public class Investor
{
public string name { get; set; }
public List<Program> programs { get; set; }
}
public class RootObject
{
public List<Investor> investors { get; set; }
}
Using Json.net you can just do:
Dictionary<string,object> result = JsonConvert.DeserializeObject<Dictionary<string,object>>(json);
foreach(var item in result)
Console.WriteLine(item.Key + " " + item.Value);
How about a simple search and replace in the JSON string ? While it might not be the most elegant solution, it would possibly be the most pragmatic one.
Maybe you could just use one reserved attribute to contain the object type, and then use the base type as shown in this article: Dynamic types with JSON.NET