code: def pages_to_json(queryset):
      
      # selection may be in the wrong order, and order matters
      queryset = queryset.order_by('tree_id', 'lft')
      return simplejson.dumps(
          {JSON_PAGE_EXPORT_NAME: JSON_PAGE_EXPORT_VERSION,
              'pages': [page.dump_json_data() for page in queryset]},
          indent=JSON_PAGE_EXPORT_INDENT, sort_keys=True)
docs: Return a JSON string export of the pages in queryset.