code: def json_to_pages(json, user, preferred_lang=None):
      
      from .models import Page
      if not preferred_lang:
          preferred_lang = settings.PAGE_DEFAULT_LANGUAGE
  
      d = simplejson.loads(json)
      try:
          errors = validate_pages_json_data(d, preferred_lang)
      except KeyError as e:
          errors = [_('JSON file is invalid: %s') % (e.args[0],)]
  
      pages_created = []
      if not errors:
          # pass one
          for p in d['pages']:
              pages_created.append(
                  Page.objects.create_and_update_from_json_data(p, user))
          # pass two
          for p, results in zip(d['pages'], pages_created):
              page, created, messages = results
              rtcs = p['redirect_to_complete_slug']
              if rtcs:
                  messages.extend(page.update_redirect_to_from_json(rtcs))
          # clean up MPTT links
          #Page.objects.rebuild()
  
      return errors, pages_created
docs: Attept to create/update pages from JSON string json.  user is the
      user that will be used when creating a page if a page's original
      author can't be found.  preferred_lang is the language code of the
      slugs to include in error messages (defaults to
      settings.PAGE_DEFAULT_LANGUAGE).
  
      Returns (errors, pages_created) where errors is a list of strings
      and pages_created is a list of: (page object, created bool,
      messages list of strings) tuples.
  
      If any errors are detected there the error list will contain
      information for the user and no pages will be created/updated.