Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-6352

FileSystem objects are not JSON-serializable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • cordova-plugin-file
    • None

    Description

      Attempting to render a FileSystem object (or a FileEntry, or DirectoryEntry, or any other object with a FileSystem contained it) results in the error:

      TypeError: JSON.stringify cannot serialize cyclic structures.
      

      (This is new behaviour with File 1.0.0)

      This happens because of a cycle in the FileSystem object structure: FileSystem contains a 'root' property, which is a DirectoryEntry. The DirectoryEntry contains a 'filesystem' property, which is the original FileSystem.

      I think that we can solve this with a .toJSON() method on the FileSystem object. This is supported (tested) on iOS and Android, and appears to be present in all versions of WebKit back to 2009. I don't believe that the presence of this method should have any side effects on webviews (if there are any) which do not support it.

      Attachments

        Issue Links

          Activity

            People

              iclelland Ian Clelland
              iclelland Ian Clelland
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: