What format for JSON Generic import?

I tried to import my data using just the API, but it looks like the recommended way is to use an importer. My data actually comes from a ListServ RSS feed that I’ve converted to json.

From a search on the issue I see that the format that I need my data in looks like this:

    "topics": [
      {
        "id": 1,
        "title": "The title",
        "pinned": false,
        "posts": [
          {
            "id": 2,
            "body": "The body",
            "date": "The date",
            "author": "username"
          }
        ]
      }
    ]
  }

First question: Is this the corrrect format for json_generic?
Second Question: Is there anymore information about how to use this?

If you can get access to the mbox files, that’ll be much easier.

The generic import script is just that, you’ll need to look at the code to see what it’s expecting and change it or your data to match.

The salient bit is here:

2 Likes

I don’t think I have access to the mbox files. I’m a subscriber with only a few of the emails from the group. I already tried this route. The system is in a different branch and I’m trying to showcase discourse to our organization.

Are you able to confirm that my json structure looks correct, minus some fields?

At first glance, it looks like you’re on the right track. But you’ll of course need to get the field names right. And you need to get the users imported for it to work.

2 Likes

I’ve got the users imported through the API already. I guess I got lucky on this one. The content doesn’t pass validations and from the looks of it, I’m not able to disable it just to send my json file up to my local discourse.

Each post will need to go and fetch the userId I suppose from discourse. Does this sound right, or is there a different approach?

You’ll want to start from scratch and have the script create the users. It needs the import id in a user custom field to do the user lookups.

Since, I need to redo the users, would this work. In this example, user 1 (John Doe) creates topic 1, “The Title”, and this topic has 1 post by John Doe with content of Body?

If this is correct, How do I use the json_generic script to start the process? I’m a little confused on the next step in the process.

  "topics": [
      {
        "id": 1,
        "user_id": "1",
        "title": "The title",
        "pinned": false,
        "posts": [
          {
            "id": 2,
            "user_id": "1",
            "body": "The body",
            "date": "The date",
            "author": "username"
          }
        ]
      }
    ],
  "users": [
       {
    "id": "1",      
    "name": "John Doe",
    "email": "John_Doe@wahoo.com",
    "password": "asfd9!t",
    "username": "John Doe",
    "active": true,
    "approved": true
  },  

]
  }
1 Like