This project is read-only.

Deserializing to a Dictionary of Dictionaries

Mar 21, 2013 at 3:43 PM
Edited Mar 21, 2013 at 7:30 PM
edit I got this to work using (Dictionary)Parse(json), but documentation doesn't seem to support that this is how it should be done. For now, I am satisfied, but there is room for improvement with ToObject()


I'm working on a localization project and would like to deserialize a json string to a Dictionary<string,object> in which some of the values may be another Dictionary<string,object> for size optimization purposes (essentially namespacing). An example of the json is below.
  "app": {
      "title": "TITLE_EN",
      "desc": "DESC_EN",
      "settings": {
          "" : "SETTINGS_EN"
          "title": "SETTINGS_TITLE_EN"
I plan to end up with something I can recurse through and flatten down into a less complex Dictionary<string,string>.
Unfortunately, attempts at using fastJSON.JSON.Instance.ToObject<Dictionary<string,object>>(json) results in an exception in mscorlib's Dictionary.cs. According to the string is valid json.

I had success using Parse(json) and ToObject(json), but it insists upon nesting IList which is undesirable to me. Do you have any recommendations on how to achieve this with fastJSON? Thanks for your hard work on this project.