Monday, October 13, 2025

c# - How to solve JSON deserialization problem

JSON deserialization returns this error:
Each parameter in the deserialization constructor on type 
'cieb_AXReportPrintDLG.ReportParamComboValues' must bind 
to an object property or field on deserialization. Each 
parameter name must match with a property or field on the 
object. Fields are only considered when 
'JsonSerializerOptions.IncludeFields' is enabled. 
The match can be case-insensitive.
All fields looks like OK. The problem is in the parameter names in the constructor. This version returns error:
public class ReportParamComboValues {

  /* description - for text */
  public string Description { get; set; }

  /* returned value for SSRS report param */
  public string Value { get; set; }

  public ReportParamComboValues( string _description, string _value ) {  
    this.Description = _description;
    this.Value = _value;
  }

}
This is working:
public class ReportParamComboValues {

  /* description - for text */
  public string Description { get; set; }

  /* returned value for SSRS report param */
  public string Value { get; set; }

  public ReportParamComboValues( string Description, string Value ) {  
    this.Description = Description;
    this.Value = Value;
  }

}

No comments:

Post a Comment