import-export Importing nested json data

Hi,
I need to import some data from json. The data contains nested objects and I’m unclear how to reference through to that data when writing the resource. I only see documentation about how to access fields at the “root” level of the data structure, not the nested levels. There is a bunch of info on exporting nested structures to json but I haven’t found anything on importing.

[{
    "somekeys": somevalues,
    "roster": [
      {
        "id": "P2021130273",
        "name": "Benja",
        "level": 85,
      },
      { more records },
    ]
}]

My goal is to map to the ids in the “roster” list. Where could I look for this information?

Thanks

PS FWIW I have a routine for importing the data using loops but was interested in trying this method.

1 Like

The only thing I can think of here would be natural-key framework where you would define a ‘get_by_natural_key’ method on the default manager (“objects”); but the roster entries would need to already exist. +1 on this question, I would like to know more.

I don’t recall seeing a lot of traffic about django-import-export here. I’m not sure how many people here use it regularly or in great detail.

Technically, this is a 3rd party package and not a part of Django. I don’t see anything listed in their docs for a preferred method of requesting support, but you may get faster and more direct assistance if you start a discussion on their discussions page on github. (Discussions · django-import-export/django-import-export · GitHub)

Thanks. I’ll check into it on their discussions page (thanks for pointing me to it) and let you know if I find a solution.

Didn’t want to leave this hanging so… I decided that using the import-export module was more trouble than it was worth so I am just looping through the data. The code is clean and easy to read so I’m just leaving it like that.

Thanks