Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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 !

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Arulprakash07 

 

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.

View solution in original post

7 Replies

Avatar

Community Advisor

Hi @Arulprakash07 

 

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 

Avatar

Level 2

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.

 

 

 

 

 

 

Avatar

Community Advisor

Hi @Arulprakash07 

 

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/Da... 

 

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/h... 

 

Hope this helps.

Avatar

Level 2

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"
}
}
}

Avatar

Correct answer by
Community Advisor

Hi @Arulprakash07 

 

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.

Avatar

Community Advisor

Hello @Arulprakash07 

 

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_Kumar__0-1670474431430.png

 

 

 


     Manoj
     Find me on LinkedIn