code: def json(self):
          
          self.pendingvalidation()
  
          jsondoc = {'id': self.id, 'children': [], 'declarations': self.jsondeclarations() }
          if self.version:
              jsondoc['version'] = self.version
          else:
              jsondoc['version'] = FOLIAVERSION
          jsondoc['generator'] = 'pynlpl.formats.folia-v' + LIBVERSION
  
          for text in self.data:
              jsondoc['children'].append(text.json())
          return jsondoc
docs: Serialise the document to a ``dict`` ready for serialisation to JSON.
  
          Example::
  
              import json
              jsondoc = json.dumps(doc.json())