Too simple for you? Check out the Technical guide.
Just looking for the node reference? Jump directly to the Index.
This library is meant to make it a bit easier to programmatically construct an ADF document from Java code. The core library operates entirely with basic Java collections, using Map<String, ?> to represent JSON objects and List<?> to represent arrays. It does, however, also provide several small adapter libraries so that you can use something like Jackson to marshall the ADF documents all the way to String and back. Or you can create your own parser, if you prefer – there’s some glue available for that, too.
This library is part of the Atlassian Platform, and is licensed to external developers under Section 3 of the Atlassian Developer Terms.
Each release is documented in the Change Log.
This project is split over several modules that are published to packages.atlassian.com with com.atlassian.adf as the groupId. They use the following artifactId values:
adf-builder-java – the core library, based around the Doc classadf-builder-java-docx – an EXPERIMENTAL parser to generate ADF from DocXadf-builder-java-gson – an adapter that uses Google GSON for JSON serializationadf-builder-java-html – an EXPERIMENTAL parser to generate ADF from HTMLadf-builder-java-jackson2 – an adapter that uses Jackson v2 for JSON serializationadf-builder-java-jackson3 – an adapter that uses Jackson v3 for JSON serializationadf-builder-java-markdown – an EXPERIMENTAL parser to generate ADF from Markdownadf-builder-java-schema – a formal JSON schema validator (requires Jackson v2)adf-builder-java-wiki - a library for converting between ADF and the legacy Wiki Markup formatThese artifacts are no longer provided. The links below provide workarounds.
adf-builder-java-jackson1 – Workaroundadf-builder-scala-playjson – WorkaroundThe most recent version of this library can be found on packages.atlassian.com. These packages and some of their dependencies are provided by Atlassian and may not be available on public mirrors. You will need to ensure that your project is configured to use the Atlassian repositories by following these instructions.
The following pom.xml excerpt should give a general idea of what you will need:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40<properties> <adf-builder-java.version>2.0.3</adf-builder-java.version> </properties> <!-- Enable Atlassian Maven repository --> <repositories> <repository> <id>atlassian-public</id> <url>https://packages.atlassian.com/mvn/maven-external/</url> <snapshots> <enabled>true</enabled> <updatePolicy>never</updatePolicy> <checksumPolicy>warn</checksumPolicy> </snapshots> <releases> <enabled>true</enabled> <checksumPolicy>warn</checksumPolicy> </releases> </repository> </repositories> <!-- Using the core library, Jackson 2 for JSON parsing, and Markdown conversion support --> <dependencies> <dependency> <groupId>com.atlassian.adf</groupId> <artifactId>adf-builder-java</artifactId> <version>${adf-builder-java.version}</version> </dependency> <dependency> <groupId>com.atlassian.adf</groupId> <artifactId>adf-builder-java-jackson2</artifactId> <version>${adf-builder-java.version}</version> </dependency> <dependency> <groupId>com.atlassian.adf</groupId> <artifactId>adf-builder-java-markdown</artifactId> <version>${adf-builder-java.version}</version> </dependency> </dependencies>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30import com.atlassian.adf.jackson2.AdfJackson2; import com.atlassian.adf.model.node.Doc; import static com.atlassian.adf.model.mark.Strong.strong; import static com.atlassian.adf.model.node.Doc.doc; import static com.atlassian.adf.model.node.Paragraph.p; import static com.atlassian.adf.model.node.Rule.hr; import static com.atlassian.adf.model.node.Text.text; public class Example { public static void main(String[] args) { Doc doc = doc( p("Hello"), hr(), p( text("world", strong()), text("!") ) ); AdfJackson2 parser = new AdfJackson2(); String json = parser.marshall(doc); System.out.println(json); Doc reconstructed = parser.unmarshall(json); if (!doc.equals(reconstructed)) { throw new AssertionError("Hmmmm... they should have matched..."); } } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37{ "type": "doc", "version": 1, "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Hello" } ] }, { "type": "rule" }, { "type": "paragraph", "content": [ { "type": "text", "text": "world", "marks": [ { "type": "strong" } ] }, { "type": "text", "text": "!" } ] } ] }
Hello
world!
Rate this page: