JAVA | Transform JSON data to XDM format as defined in AEP schema using JAVA | Community
Skip to main content
Level 2
December 8, 2022
Solved

JAVA | Transform JSON data to XDM format as defined in AEP schema using JAVA

  • December 8, 2022
  • 2 replies
  • 3201 views

Can some one please share how to transfor JSON data to XDM format in JAVA.

 

Scenario: My Java application consumes JSON data that needs to transform into XDM format as defined in schema and inject that data into AEP.

 

Documentation link is also fine If that helps to do transformation using JAVA from JSON to XDM as defined in AEP schema.

 

Thanks in advance !

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Avinash_Gupta_

Thanks @avinash_gupta_ and @_manoj_kumar_ , Please refer below source data and transferred data. Here, Source data transferred using NodeJS in the XDM format.

 

Needs to do same transformation using JAVA, Kindly share your thoughts.

 

Appreciate your supports !

 

Source Data:
{
"myPlace": "AWS",
"account": "12378",
"PlannedDate": "2022-11-02T09:14:57Z",
"delayDays": "2",
"assetType": "mobile"

}

 

Transformed Data:
{
"header": {
"schemaRef": {
"id": "https://ns.adobe.com/test/schemas/f1234567",
"contentType": "application/vnd.adobe.xed-full+json;version=1.0"
},
"source": {
"name": "aws"
}
},
"body": {
"xdmMeta": {
"schemaRef": {
"id": "https://ns.adobe.com/test/schemas/f1234567",
"contentType": "application/vnd.adobe.xed-full+json;version=1.0"
}
},
"xdmEntity": {
"myType": "mobile",
"_id": "sdsdsd1234",
"_mobile": {
"group": {
"my_place": "AWS",
"delay_days": 2,
"planned_date": "2022-11-02T09:14:57.000+00:00"
},
"my_group": {
"account": "12378",
"encrypted_account": "+a23def=="
}
},
"time": "2022-11-02T09:14:57.000+00:00"
}
}
}


Hi @arulprakashve 

 

I don't think there is any OOB feature available in AEP to transform your source JSON. You would have to write your own custom utility in java to transform the JSON. Various methods are available like Google GSON, Jackson in java that you can use to transform the JSON.

 

https://mkyong.com/java/how-do-convert-java-object-to-from-json-format-gson-api/ 

https://mkyong.com/java/jackson-2-convert-java-object-to-from-json/ 

 

Hope this helps.

2 replies

Avinash_Gupta_
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
December 8, 2022

Hi @arulprakashve 

 

Why do you need to convert JSON data to XDM format? You can directly ingest json data into AEP. There are various ingestion process that you can choose from and ingest the JSON data into AEP. There is no need to convert it into XDM format.

 

Also, XDM is built on top of JSON Schema, and therefore XDM fields inherit a similar syntax when defining their type.

 

Here are some ingestion method:-

https://experienceleague.adobe.com/docs/experience-platform/ingestion/home.html?lang=en 

Level 2
December 8, 2022

Hi @avinash_gupta_,

 

Thanks for your reply, I don't see in particular JSON ingestion in that link. Please highlight the exact URL

 

Actually currently using NodeJS to transform the data from JSON to XDM and injecting into AEP. Instead of NodeJS, planning to use the existing JAVA application to feed the data into AEP.

 

 

 

 

 

 

Avinash_Gupta_
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
December 8, 2022

Hi @arulprakashve 

 

If you are trying to feed the JSON data created from Java application to AEP, I would suggest you to use AEP batch or streaming ingestion (In real time) API method . You can use the HTTP post client in Java and execute the methods

 

Here is the documentation of API collection: 

https://developer.adobe.com/experience-platform-apis/references/data-ingestion/#tag/Batch-Ingestion 

 

POSTMAN collection: 

https://github.com/adobe/experience-platform-postman-samples/blob/master/apis/experience-platform/Data%20Ingestion%20API.postman_collection.json 

 

Follow the below documentation to understand about the sequence of ingestion using streaming HTTP API ingestion. Some of the steps mentioned in this documentation you can create using UI and rest using API.

 

https://experienceleague.adobe.com/docs/experience-platform/sources/api-tutorials/create/streaming/http.html?lang=en 

 

Hope this helps.

Manoj_Kumar
Community Advisor
Community Advisor
December 8, 2022

Hello @arulprakashve 

 

There is no XDM format, the way JSON is structured for data ingestion in AEP is called XDM format. But it is still the JSON data payload.

 

To get the structure of the XDM, you can go to the schema in AEP and download the Sample  JSON format. It will give you the required JSON structure.

 

 

 

 

Manoj  | https://themartech.pro