.NET 8.0 NewtonSoft.Json exception in deserializer

290 Views Asked by At

I want to deserialize an object from class using RestSharp library like this:

ResponseModel.Root mdl = 
    JsonConvert.DeserializeObject<ResponseModel.Root>(response.Content);

This is based on this model classes:

// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class ContextAssignedTo
{
    public string _id { get; set; }
    public string Name { get; set; }
    public string Kind { get; set; }
}

public class CreatedBy
{
    public string _id { get; set; }
    public string Name { get; set; }
    public string Kind { get; set; }
}

public class CurrentAssignedTo
{
    public string _id { get; set; }
    public string Name { get; set; }
    public string Kind { get; set; }
}

public class CurrentContext
{
    public string _context_current_step { get; set; }
    public string _context_activity_id { get; set; }
    public string NodeType { get; set; }
    public List<object> _context_action_info { get; set; }
    public string _context_activity_instance_id { get; set; }
    public string _status { get; set; }
    public List<ContextAssignedTo> _context_assigned_to { get; set; }
    public DateTime _context_assigned_at { get; set; }
}

public class Look
{
    public string Name { get; set; }
    public string Section_English { get; set; }
    public string Employee_Name_English { get; set; }
    public string Division_English { get; set; }
    public string Manager_Name_English { get; set; }
    public string Email_Address { get; set; }
    public string _id { get; set; }
}

public class LookJSON
{
    public string GL_Description { get; set; }
    public string _id { get; set; }
    public string Name { get; set; }
}

public class ModifiedBy
{
    public string _id { get; set; }
    public string Name { get; set; }
    public string Kind { get; set; }
}

public class Root
{
    public string _id { get; set; }
    public string Name { get; set; }
    public CreatedBy _created_by { get; set; }
    public ModifiedBy _modified_by { get; set; }
    public DateTime _created_at { get; set; }
    public DateTime _modified_at { get; set; }
    public string _flow_name { get; set; }
    public string _flow_type { get; set; }
    public string _doc_version { get; set; }
    public string _current_step { get; set; }
    public List<CurrentAssignedTo> _current_assigned_to { get; set; }
    public string _status { get; set; }
    public int _stage { get; set; }
    public string _root_process_instance { get; set; }
    public DateTime _submitted_at { get; set; }
    public int _request_number { get; set; }
    public int _counter { get; set; }
    public string _last_completed_step { get; set; }
    public int _progress { get; set; }
    public Look look { get; set; }
    public string CreatedByName { get; set; }
    public string CreatedByFN { get; set; }
    public string CreatedByLN { get; set; }
    public string CreatedByEm { get; set; }
    public string ConcateEm { get; set; }
    public string Modified_By { get; set; }
    public string UsN { get; set; }
    public string ConcateFNameTrim { get; set; }
    public string Untitled_Field { get; set; }
    public string ConcateNameTrim { get; set; }
    public string ConcateFNC5 { get; set; }
    public string ConcateEmC6 { get; set; }
    public string ConcateFLTrimForC1 { get; set; }
    public string PICJOConcateFLNC1 { get; set; }
    public string PICJOConcateFName { get; set; }
    public string PICJOConcateFNameTrim { get; set; }
    public string PICJOConcateFLNC2 { get; set; }
    public string PICJOConcateFLNC2_1 { get; set; }
    public string PICJOConcateNameTrimC3 { get; set; }
    public string PICJOConcateFNC5 { get; set; }
    public string PICJOConcateEmC6 { get; set; }
    public string PICJOConcateFLTrimForC1 { get; set; }
    public string SpecialAxantiaDomain { get; set; }
    public string TempFormula { get; set; }
    public string TeEmTxt { get; set; }
    public string JSONFormula { get; set; }
    public LookJSON LookJSON { get; set; }
    public string CompanyCode { get; set; }
    public string Docdate { get; set; }
    public string PostingDate { get; set; }
    public string FiscalYear { get; set; }
    public string FiscalPeriod { get; set; }
    public string DocType { get; set; }
    public string ReferenceDocNumber { get; set; }
    public string DocumentStatus { get; set; }
    public string VendorItemNumber { get; set; }
    public string VendorNumber { get; set; }
    public string SPL_GL_IND { get; set; }
    public string UserName { get; set; }
    public string HeaderText { get; set; }

    [JsonProperty("Table::Account_GL")]
    public List<TableAccountGL> TableAccount_GL { get; set; }

    [JsonProperty("Table::Currency_1")]
    public List<TableCurrency1> TableCurrency_1 { get; set; }

    [JsonProperty("Table::Extension")]
    public List<TableExtension> TableExtension { get; set; }
    public List<CurrentContext> _current_context { get; set; }
    public string _meta_version { get; set; }
}

public class TableAccountGL
{
    public string _id { get; set; }
    public CreatedBy _created_by { get; set; }
    public ModifiedBy _modified_by { get; set; }
    public DateTime _created_at { get; set; }
    public DateTime _modified_at { get; set; }
    public string ITEMNO_ACC { get; set; }
    public string CostCenter { get; set; }
    public string OrderID { get; set; }
    public string OrderITNumber { get; set; }
    public string ProfitCenter { get; set; }
    public string GL_ACCOUNT { get; set; }
}

public class TableCurrency1
{
    public string _id { get; set; }
    public CreatedBy _created_by { get; set; }
    public ModifiedBy _modified_by { get; set; }
    public DateTime _created_at { get; set; }
    public DateTime _modified_at { get; set; }
    public string AMT_DOCCUR { get; set; }
    public string CURRENCY_2 { get; set; }
    public string ITEMNO_ACC_1 { get; set; }
}

public class TableExtension
{
    public string _id { get; set; }
    public CreatedBy _created_by { get; set; }
    public ModifiedBy _modified_by { get; set; }
    public DateTime _created_at { get; set; }
    public DateTime _modified_at { get; set; }
    public string Ext_Line_Number { get; set; }
    public string Ext_Posting_Key { get; set; }
}

I get this error :

An exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll but was not handled in user code Input string '0.0' is not a valid integer. Path '_progress', line 1, position 749.

I hope to fix this issue.

I tried to convert from JSON to C# in multiple ways like past special JSON as C# Classes option and other to ensure that the problem is not from the model.

this is the json response below:

{
  "_id": "Pk8CNpujq8zL",
  "Name": "Process Testing from Yazeed Alwkhyan",
  "_created_by": {
    "_id": "Us5eox3C7Swl",
    "Name": "Yazeed Alwkhyan",
    "Kind": "User"
  },
  "_modified_by": {
    "_id": "Us5eox3C7Swl",
    "Name": "Yazeed Alwkhyan",
    "Kind": "User"
  },
  "_created_at": "2023-11-15T10:06:48Z",
  "_modified_at": "2023-12-04T22:00:19Z",
  "_flow_name": "Process Testing",
  "_flow_type": "Process",
  "_doc_version": "129908520699136320",
  "_current_step": "Test",
  "_current_assigned_to": [
    {
      "_id": "Us5eox3C7Swl",
      "Name": "Yazeed Alwkhyan",
      "Kind": "User"
    }
  ],
  "_status": "InProgress",
  "_stage": 1,
  "_root_process_instance": "Pk8CNpuqIuZV",
  "_submitted_at": "2023-11-15T10:07:04Z",
  "_request_number": 52,
  "_counter": 72,
  "_last_completed_step": "Pk8CQ1SHJL8b",
  "_progress": 0,
  "look": {
    "Name": "934",
    "Section_English": "Strategy & Business Development",
    "Employee_Name_English": "Tamer Sami Bulti Haddad",
    "Division_English": "Licensing & Alliance Management",
    "Manager_Name_English": "Wahid Loai Wahid Al Oran",
    "Email_Address": "[email protected]",
    "_id": "AxantiaEmployeeProfileDataSet_5kNXi2jWeE"
  },
  "CreatedByName": "@gmail.com",
  "CreatedByFN": "[email protected]",
  "CreatedByLN": "@gmail.com",
  "CreatedByEm": "[email protected]",
  "ConcateEm": "[email protected]",
  "Modified_By": "Yazeed Alwkhyan",
  "UsN": "Email:  | FullName:  | FirstName:  | LastName:  |FirstLastName|  ",
  "ConcateFNameTrim": "",
  "Untitled_Field": "[email protected]",
  "ConcateNameTrim": "@gmail.com",
  "ConcateFNC5": "@gmail.com",
  "ConcateEmC6": "",
  "ConcateFLTrimForC1": "[email protected]",
  "PICJOConcateFLNC1": "@gmail.com",
  "PICJOConcateFName": "[email protected]",
  "PICJOConcateFNameTrim": "@gmail.com",
  "PICJOConcateFLNC2": "",
  "PICJOConcateFLNC2_1": "[email protected]",
  "PICJOConcateNameTrimC3": "@gmail.com",
  "PICJOConcateFNC5": "@gmail.com",
  "PICJOConcateEmC6": "@gmail.com",
  "PICJOConcateFLTrimForC1": "[email protected]",
  "SpecialAxantiaDomain": "[email protected]",
  "TempFormula": "[email protected]",
  "TeEmTxt": "@gmail.com",
  "JSONFormula": "\"AccountGL\":\"[{\"\": \"Account_GL_Sq6ddIbXE\", \"_created_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:06:52Z\", \"_modified_at\": \"2023-11-15T10:08:14Z\", \"GL_Account\": \"7965123\", \"Item_Acc\": \"13265478\", \"Cost_Center\": \"6456\"}, {\"\": \"Account_GL_pv6czQkzp\", \"_created_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:08:05Z\", \"_modified_at\": \"2023-11-15T10:08:19Z\", \"GL_Account\": \"5645645\", \"Item_Acc\": \"5456123\", \"Cost_Center\": \"5456\"}, {\"\": \"Account_GL_hjpeTRu4Cj\", \"_created_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:08:19Z\", \"_modified_at\": \"2023-11-15T10:08:22Z\", \"GL_Account\": \"5645645\", \"Item_Acc\": \"5645645\", \"Cost_Center\": \"5645645\"}]\"",
  "LookJSON": {
    "GL_Description": "\"AccountGL\":\"[{\"_id\": \"Account_GL_Sq6ddIbXE\", \"_created_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:06:52Z\", \"_modified_at\": \"2023-11-15T10:08:14Z\", \"GL_Account\": \"7965123\", \"Item_Acc\": \"13265478\", \"Cost_Center\": \"6456\"}, {\"_id\": \"Account_GL_pv6czQkzp\", \"_created_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:08:05Z\", \"_modified_at\": \"2023-11-15T10:08:19Z\", \"GL_Account\": \"5645645\", \"Item_Acc\": \"5456123\", \"Cost_Center\": \"5456\"}, {\"_id\": \"Account_GL_hjpeTRu4Cj\", \"_created_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_modified_by\": {\"_id\": \"Us5eox3C7Swl\", \"Name\": \"Yazeed Alwkhyan\", \"Kind\": \"User\"}, \"_created_at\": \"2023-11-15T10:08:19Z\", \"_modified_at\": \"2023-11-15T10:08:22Z\", \"GL_Account\": \"5645645\", \"Item_Acc\": \"5645645\", \"Cost_Center\": \"5645645\"}]\"",
    "_id": "Axantia_DataSet_3_8COGRos_7b",
    "Name": "Pk8COGGJEwHa"
  },
  "CompanyCode": "6800",
  "Docdate": "04/12/2023",
  "PostingDate": "04/12/2023",
  "FiscalYear": "2023",
  "FiscalPeriod": "12",
  "DocType": "KR",
  "ReferenceDocNumber": "12345",
  "DocumentStatus": "2",
  "VendorItemNumber": "10",
  "VendorNumber": "7003024",
  "SPL_GL_IND": "L",
  "UserName": "Yazeed Alwkhyan",
  "HeaderText": "SDE",
  "Table::Account_GL": [
    {
      "_id": "Account_GL_Sq6ddIbXE",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-11-15T10:06:52Z",
      "_modified_at": "2023-12-04T22:00:17Z",
      "ITEMNO_ACC": "7965123",
      "CostCenter": "7965123",
      "OrderID": "7965123",
      "OrderITNumber": "7965123",
      "ProfitCenter": "7965123",
      "GL_ACCOUNT": "7965123"
    },
    {
      "_id": "Account_GL_pv6czQkzp",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-11-15T10:08:05Z",
      "_modified_at": "2023-12-04T22:00:17Z",
      "ITEMNO_ACC": "7965123",
      "CostCenter": "7965123",
      "OrderID": "7965123",
      "OrderITNumber": "7965123",
      "ProfitCenter": "7965123",
      "GL_ACCOUNT": "7965123"
    },
    {
      "_id": "Account_GL_hjpeTRu4Cj",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-11-15T10:08:19Z",
      "_modified_at": "2023-12-04T22:00:17Z",
      "ITEMNO_ACC": "7965123",
      "CostCenter": "7965123",
      "OrderID": "7965123",
      "OrderITNumber": "7965123",
      "ProfitCenter": "7965123",
      "GL_ACCOUNT": "7965123"
    }
  ],
  "Table::Currency_1": [
    {
      "_id": "Currency_1__v5Dl3Zn4",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T08:55:52Z",
      "_modified_at": "2023-12-04T08:56:01Z",
      "AMT_DOCCUR": "7965123",
      "CURRENCY_2": "7965123",
      "ITEMNO_ACC_1": "7965123"
    },
    {
      "_id": "Currency_1_uNO9tmy22",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T08:55:53Z",
      "_modified_at": "2023-12-04T08:56:01Z",
      "AMT_DOCCUR": "7965123",
      "CURRENCY_2": "7965123",
      "ITEMNO_ACC_1": "7965123"
    },
    {
      "_id": "Currency_1_tkffSA2mM",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T08:55:54Z",
      "_modified_at": "2023-12-04T08:56:01Z",
      "AMT_DOCCUR": "7965123",
      "CURRENCY_2": "7965123",
      "ITEMNO_ACC_1": "7965123"
    }
  ],
  "Table::Extension": [
    {
      "_id": "Extension_pnq2ZiJEG",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T09:16:15Z",
      "_modified_at": "2023-12-04T09:16:22Z",
      "Ext_Line_Number": "7965123",
      "Ext_Posting_Key": "7965123"
    },
    {
      "_id": "Extension_KQTy5k4Al",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T09:16:15Z",
      "_modified_at": "2023-12-04T09:16:22Z",
      "Ext_Line_Number": "7965123",
      "Ext_Posting_Key": "7965123"
    },
    {
      "_id": "Extension_0GQUaaZK4",
      "_created_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_modified_by": {
        "_id": "Us5eox3C7Swl",
        "Name": "Yazeed Alwkhyan",
        "Kind": "User"
      },
      "_created_at": "2023-12-04T09:16:17Z",
      "_modified_at": "2023-12-04T09:16:22Z",
      "Ext_Line_Number": "7965123",
      "Ext_Posting_Key": "7965123"
    }
  ],
  "_current_context": [
    {
      "_context_current_step": "Test",
      "_context_activity_id": "Activity_AfGS8cnE8",
      "NodeType": "MultiUserTask",
      "_context_action_info": [],
      "_context_activity_instance_id": "Pk8CQ1YZSOzr",
      "_status": "InProgress",
      "_context_assigned_to": [
        {
          "_id": "Us5eox3C7Swl",
          "Name": "Yazeed Alwkhyan",
          "Kind": "User"
        }
      ],
      "_context_assigned_at": "2023-11-15T12:23:35Z"
    }
  ],
  "_meta_version": "13213213"
}```
0

There are 0 best solutions below