0

I need to deserialize this json

{
    "partnerName": "moha",

    "monetic.to_use": "skynet",
    "monetic.mb_id": "MB.00.T",
    "monetic.currency": 978,

    "monetic.atos.merchant_id": "011223344553333",
    "monetic.atos.is_shared": true,
    "monetic.atos.data_config": "",
}

into this complex structure

class Config {
    string partnerName;
    Monetic monetic;
}

class Monetic {
    string to_use;
    string mb_id;
    int currency;
    Atos atos;
}

class Atos {
    string merchant_id;
    bool is_shared;
    string data_config;
}

Is there any better (more generic) way to do than manually binding each properties?

Update: We always have only one "complex" item (like monetic)

Hiep
  • 2,483
  • 1
  • 25
  • 32
  • Is there a possibility that more than one any item(like monetic) – levent Feb 16 '17 at 18:27
  • 2
    If you can use [tag:json.net], I think this should meet your requirement: [Can I specify a path in an attribute to map a property in my class to a child property in my JSON?](http://stackoverflow.com/q/33088462/3744182). – dbc Feb 16 '17 at 19:29
  • @levent: No, we always have only one "complex" item – Hiep Feb 17 '17 at 00:21
  • 1
    @dbc: wao! it is quite close to what I need. May be a little tweaks the JsonPathConverter would do the job. I will try. Thanks! – Hiep Feb 17 '17 at 00:33

0 Answers0