1

What i have:

  1. A WebAPI Service which contains the businesslogic and works with JSON
  2. A client which sends requests to the WebAPI and waits for responses
  3. An interface "IBusinesspartner" and 2 Objects which inherits from the interface: "Businesspartner" and "Potential".

What i need:

I need to deserialize an interface to JSON which contains some other custom objects. Like this: IBusinesspartner

public string Name { get; set; }
public string Street { get; set; }
public SalesDivision Division { get; set; }
public IDictionary<SalesDivison, Money> TurnoverPerDivision { get; set; }

What i already did:

i used this thread to implement a custom converter which seems to work fine to deserialize the JSON String which i get as response from the WebAPI Service until it needs to deserialize the Dictionary.. then i get the following error message:

Could not convert string 'BL.Service.Models.SalesDivision' to dictionary key type 'data.model.SAP.SalesDivision'. Create a TypeConverter to convert from the string to the key type object. Path 'TurnoverPerSalesDivision.BL.Service.Models.SalesDivision', line 1, position 17672.

the question:

yes i know the error message tells me what to do but i still don't explicit know what i have to do in my next step. Shall i rework / extend my just implemented converter for the IBusinesspartner interface or shall i create an own converter for each of my objects ? how could such a converter look like? any examples maybe? i would be happy about any help and information i can get.

Community
  • 1
  • 1
darkdog
  • 3,805
  • 7
  • 37
  • 47

0 Answers0