Ning import script

Yeah the NING json is full of errors like missing commas, extra brackets, etc. I think I handled all of them in the repair_json method, but you might have discovered more. It’s difficult to find out what the errors are…

To share my pain, I’ll paste the repair code here:

  def repair_json(arg)
    arg.gsub!(/^\(/, "")     # content of file is surround by ( )
    arg.gsub!(/\)$/, "")

    arg.gsub!(/\]\]$/, "]")  # there can be an extra ] at the end

    arg.gsub!(/\}\{/, "},{") # missing commas sometimes!

    arg.gsub!("}]{", "},{")  # surprise square brackets
    arg.gsub!("}[{", "},{")  # :troll:

    arg
  end

Also… note that the Ning exporter will truncate discussions to the most recent (or oldest?) 100 posts. If you have any topics with more posts than that, you’ll have to contact Ning support directly to get the full export data.

5개의 좋아요