Document JSON is a serializable representation of the current changes to a document, i.e. a diff between the [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document)’s saved and unsaved changes. This can be used to transfer a set of changes across devices without having to send the entire PDF, which could potentially be very large. [Nutrient Web SDK](https://www.nutrient.io/sdk/web/) uses this in standalone deployment to reduce bandwidth use. Currently, the generated JSON only contains changes to annotations.

To generate Instant JSON for a document, call [`Document.generateInstantJSON(from:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/generateinstantjson(from:)) on the document from which you wish to retrieve currently unsaved changes in JSON form. Note that this method will return `nil` if there are no unsaved changes in the document:

```swift

let data = try? document.generateInstantJSON(from: document.documentProviders.first)

```

This generated data can be sent using an HTTP request to your server. Similarly, you can fetch the JSON data from your server, and it can then be applied to a document using [`Document.applyInstantJSON(fromDataProvider:to:lenient:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document/applyinstantjson(fromdataprovider:to:lenient:)). If you have an `NSData` object containing the Document JSON data, create a [`DataContainerProvider`](https://www.nutrient.io/api/ios/documentation/pspdfkit/datacontainerprovider) and pass that as the `dataProvider` argument to the method, like this:

```swift

let document =...
let jsonContainer = DataContainerProvider(data:data!)
do {
    try document.applyInstantJSON(fromDataProvider: jsonContainer, to: document.documentProviders.first, lenient: false)
} catch {
    print("Error: \(error).")
    return
}

```

For more details, see the Instant JSON — Document example from [`InstantJSONExamples.swift`](https://github.com/PSPDFKit/pspdfkit-ios-catalog/blob/master/Catalog/Examples/Annotations/InstantJSONExamples.swift) in [Nutrient Catalog](https://github.com/PSPDFKit/pspdfkit-ios-catalog).
---

## Related pages

- [Advanced CocoaPods integration](/guides/ios/miscellaneous/advanced-cocoapods-integration.md)
- [App Transport Security](/guides/ios/pspdfkit-instant/app-transport-security.md)
- [Advanced Carthage integration](/guides/ios/miscellaneous/advanced-carthage-integration.md)
- [Bitcode](/guides/ios/faq/bitcode.md)
- [Carthage integration](/guides/ios/best-practices/carthage-integration.md)
- [Framework Size](/guides/ios/faq/framework-size.md)
- [Airdrop](/guides/ios/features/airdrop.md)
- [Customizing The Page Number](/guides/ios/customizing-pdf-pages/customizing-the-page-number.md)
- [Nightly Builds](/guides/ios/best-practices/nightly-builds.md)
- [About Memory Usage](/guides/ios/memory-and-storage/about-memory-usage.md)
- [Customizing the log level on iOS](/guides/ios/features/logging.md)
- [iOS PDF SDK security](/guides/ios/faq/sdk-security.md)
- [Powered By Nutrient](/guides/ios/miscellaneous/powered-by-nutrient.md)
- [Optimize PDF documents for mobile rendering on iOS](/guides/ios/miscellaneous/optimize-pdf-documents-for-mobile-rendering.md)
- [Third Party Compatibility](/guides/ios/miscellaneous/third-party-compatibility.md)
- [Reduce App Size](/guides/ios/best-practices/reduce-app-size.md)
- [Modifying permissions in your iOS app](/guides/ios/getting-started/permissions.md)
- [Saving Data Externally](/guides/ios/memory-and-storage/saving-data-externally.md)
- [Using Document Efficiently](/guides/ios/getting-started/using-document-efficiently.md)
- [Using Automatic Saving Safely](/guides/ios/best-practices/using-automatic-saving-safely.md)
- [Manage your iOS status bar with view controllers](/guides/ios/faq/view-controller-based-status-bar-appearance.md)
- [Strategies For Multiple Bundle Ids](/guides/ios/faq/strategies-for-multiple-bundle-ids.md)
- [Youtube Links](/guides/ios/miscellaneous/youtube-links.md)
- [Version Numbering](/guides/ios/best-practices/version-numbering.md)

