Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

issue with json data for composite field in content fragment

Avatar

Avatar
Level 1
O703980
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
O703980
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
O703980
Level 1

13-05-2021

Implemented composite multifield.

http://experience-aem.blogspot.com/2018/10/aem-6420-assets-content-fragments-coral-3-composite-multi... 

 

Need the array to be json array than string array.

 

issue json coming as String Array

0 "{\"linkName\":\"test\",\"linkUrl\":\"test\"}"
1 "{\"linkName\":\"test\",\"linkUrl\":\"test\"}"

 

expected as json array as below.

0 {\"linkName\":\"test\",\"linkUrl\":\"test\"}
1 {\"linkName\":\"test\",\"linkUrl\":\"test\"}

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

551 likes

Total Posts

663 posts

Correct Reply

191 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

551 likes

Total Posts

663 posts

Correct Reply

191 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

14-05-2021

Hi @O703980 

 

The String Array that you have mentioned is a valif JSON whereas the expected JSON array you mentioned is not a valid JSON.

 

do you mean by:

[{\"linkName\":\"test\",\"linkUrl\":\"test\"}, {\"linkName\":\"test\",\"linkUrl\":\"test\"}]

to 

"[{\"linkName\":\"test\",\"linkUrl\":\"test\"}, {\"linkName\":\"test\",\"linkUrl\":\"test\"}]"

 

If that's the case you can use the Gson API.

 

String x = input;
Gson gson = new Gson();
String toJson = gson.toJson(x);