How to serialize IDictionary

前端 未结 3 489
无人及你
无人及你 2020-12-20 20:12

Does anyone know of a creative way to serialize objects that implement IDictionary? ...without implementing a new class?

3条回答
  •  执笔经年
    2020-12-20 20:12

    I take it you mean you have to serialize a dictionary that's part of class you have no control over?

    In short, you have to serialize the keys and values separately. To deserialize, step through each item in the key/value arrays and add them back to your dictionary.

提交回复
热议问题