amirziai/flatten

Option to leave some structure intact

Opened this issue · 1 comments

It would be great to be able to specify that some fields at root level are not to be flattened but will still be outputted.

Here is an example: json
In the above, if you look under the key "solr_additions", there are many values in the list (one for each country in Africa). It would be great to output this, because it is useful, but not flatten it as it results in more than 50 keys ie. output it unflattened.

The point of flatten to me is that the resulting object has no structure (no iterables other than strings are present as values of the flat dictionary). This way you can easily pass the dictionary to Pandas.

The unflattened structure would need to be converted into a long string and in the above case, put under a single key called "solr_additions". json_normalize in Pandas behaves this way (but obviously doesn't have all the other flattening features of this library).

I don't know how this could be achieved outside flatten.

If I were to rank usefulness to me, it would be:

  1. This ticket
  2. #13
  3. #12

Relative to the other 2, I think this one is much simpler to implement and easier to set up for the end user. The other 2 are for power users. Just my two cents.