Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i am using post API to send the data from the API
my problem is that i have data from json forms which is coming from the API. after that when i am using

JsonConvert.DeserializeObject<list<newpartlist_nrcdb>>(Result);


and saving this into a list

list<classname> obj=JsonConvert.DeserializeObject<list<newpartlist_nrcdb>>(Result);


so it is showing
"can not deserialize the current json object"

please give me some hint and how to solve this problem

i am sending json object also

What I have tried:

{"Token":null,"Status":"Success","Error_Code":1,"Result":{"List":[{"PM_Id":0,"PM_OUID":0,"PM_OUID_Name":null,"PM_PartNo":"DK120","PM_PartDescription":"BATTERY-ULB","PM_HSNCode":"","PM_PartType":null,"PM_PartType_N":"Component","PM_PartCategory":null,"PM_PartCategory_N":"ATR-SPECIFIC","PM_ReferenceStatus":null,"PM_ReferenceStatus_N":"ACTIVE","PM_PartControlType":null,"PM_PartControlType_N":"Serial","PM_LotNoTypeNum":null,"PM_LotNoTypeNum_N":"","PM_PlanningType":null,"PM_IssueBasis":null,"PM_ExpenseType":null,"PM_StockUOM":"EA","PM_PurchaseUOM":null,"PM_PartAccountGroup":null,"PM_ShelfLifeUnit":null,"PM_CalibrationApplicable":null,"PM_DesignedShelfLife":0,"PM_MinimumShelfLife":0,"PM_ShelfLifeAlertValue":0,"PM_ShelfLifeExtendable":null,"PM_ValuationMethod":null,"PM_ReplenishmentActivityBy":null,"PM_ReorderActivatedAt":null,"PM_MinQty":0,"PM_MaxQty":0,"PM_ReorderLevel":0,"PM_ReorderQty":0,"PM_MinimumIssueQty":0,"PM_SafetyStock":0,"PM_ActionOnPhaseout":null,"PM_CertificateRequired":null,"PM_ExpensingPolicy":null,"PM_ComponentIdGeneration":null,"PM_ABCClass":null,"PM_XYZClass":null,"PM_FSNClass":null,"PM_VEDClass":null,"PM_PlacementStrategy":null,"PM_PickingStrategy":null,"PM_Allocable":null,"PM_AnnualConsumption":null,"PM_CR_By":"RAMCO","PM_CR_Date":"2019-05-03T00:00:00","PM_MD_By":"RAMCO","PM_MD_Date":"2019-05-03T00:00:00","PM_Timestamp":0,"Part_N":null,"PM_ExpenseType_N":null,"QRimagePath":null,"Serial_No":null,"Calibration_Due_Date":null,"Warehouse":null,"ErrorMessage":null,"Result":null,"Result1":null,"DT":null,"DS":null,"EditStatus":false,"TempID":0,"DocNumberingType":null,"RoleName":null,"RoleID":0,"LoginID":null,"NRCStatus":null,"TaskStatus":null}],"View_Tools":null},"ErrorMessage":null,"ID":null}
Posted
Updated 28-Feb-23 22:08pm
v2
Comments
Andre Oosthuizen 28-Feb-23 7:37am    
Error_Code":1Error_Code":1 - What does error code 1 say went wrong?

This might also help - Cannot deserialize the current JSON object[^]

1 solution

The JSON you've shown is a single object; you can't deserialize that into a list.

Pasting your JSON into quicktype[^] will give you an idea of the classes you need to use:
C#
public partial class Root
{
    [JsonProperty("Token")]
    public object Token { get; set; }

    [JsonProperty("Status")]
    public string Status { get; set; }

    [JsonProperty("Error_Code")]
    public long ErrorCode { get; set; }

    [JsonProperty("Result")]
    public Result Result { get; set; }

    [JsonProperty("ErrorMessage")]
    public object ErrorMessage { get; set; }

    [JsonProperty("ID")]
    public object Id { get; set; }
}

public partial class Result
{
    [JsonProperty("List")]
    public List[] List { get; set; }

    [JsonProperty("View_Tools")]
    public object ViewTools { get; set; }
}
Deserialize the JSON as a Root instance, and access the Result.List properties to get the list back.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900