in reply to Building an arbitrary-depth, multi-level hash

++ to GrandFather for asking about the wider problem.

It seems like the first question here is figuring out how the data in file format 1 maps to the data in file formats 2,3,4, etc. To work out this problem I would:

  1. Do a data model of each file format
  2. Note differences in terminology and cardinality of relationships. For example, is "category" in format 1 equivalent to "menu" in format 2? Does format X allow for recursive menus? Does format Y? Can a menu item belong to more than one menu? And so on.
  3. Note differences in data available for each format. For example, file format 2 appears to have four bits of information per menu item, whereas format 1 has only two (assuming each name/icon corresponds to a menu item)
  4. Define a standard data model that represents all available data
  5. For formats with missing information define defaults

And now that you have worked out the design issues, you can start thinking about how to morph file formats one into another. For a given format X and Y, this will involve two steps:

  1. Read in a file in format X and convert its data to the standard data model
  2. Traverse the standard data model to output the data in format Y.

You will need a read_format_to_standard() subroutine for each input format and a write_format_from_standard() routine for each output format. But without a good idea of the standard and how each format maps to it, you will be running in circles writing any of these.

Best, beth