0

Am trying create w REST service using WCF to cater for a particular use case but the way it is structured makes it unable to bind. The structure is as follows:

    {
"1387213536":{
               "ext_id":"1",
               "unit_id":"0",
               "currency":"EUR",
               "login_hash": ""
},
"1387213537":{
               "ext_id":"1",
               "unit_id":"0",
               "currency":"EUR",
               "login_hash": "" 
 }
}

Does anyone have any idea to what type of object would this translate to? I tried to create a Dictionary<string, Dictionary<string, string>>

but it still fails to bind.

Thanks in advance

  • Create a class with same members (ext_id, unit_id, currency, login_hash). But, a side question: if you intend to use restful services, why not to use WebApi instead of WCF? – Ricardo Pontual Sep 22 '16 at 12:32
  • It's not easy with WCF. You want to set [`DataContractJsonSerializerSettings.UseSimpleDictionaryFormat`](https://stackoverflow.com/questions/33773239/) but it's never exposed, so you'll need to replace the entire serializer. See https://stackoverflow.com/questions/6792785 or https://stackoverflow.com/questions/11003016. Possibly https://stackoverflow.com/questions/33554997 will be required also. If you just need to **return** a dictionary, see https://stackoverflow.com/questions/35490329 – dbc Sep 23 '16 at 06:30

0 Answers0