• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

A quick note about Document Generation and your data

Adobe Employee ,
Nov 02, 2022 Nov 02, 2022

Copy link to clipboard

Copied

I was recently helping one of our users when I discovered something that may not be terribly clear in our docs. When we talk about the Document Generation API, we say that you can use any data you want, as long as it can be converted to JSON (which is handled by the SDK). 

 

There is as small caveat to that. The data you send to use must be an object, and by that I mean a set of key/value pairs. So for example:

 

{
"name":"ray",
"hobbies":[
   "video games",
   "books",
   "sleep"
]
}

In the example above, we have an object with two keys, name and hobbies. Arrays are just fine... just not as the 'top level' object. This means the following would *not* work with our service:

 

[
"foo","moo","goo"
]

That is certainly a valid 'object' and could be converted to JSON, but it won't work with our service.

So - this serves as an excellent reminder that while you can source your data from anything, sometimes you may need to 'shape' your data ahead of time. If your data is an array, like above, just wrap it in an object:

{
"stuff": [ "foo","moo","goo" ]
}

This is also useful when the formatting functions that work in JSONata aren't expressive enough for your needs. You can simply format your data yourself before sending it.

 

Let me know if any of this doesn't make sense!

 

TOPICS
Document Generation API

Views

28

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources