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

Getting properties from node and storing in String[]

Avatar

Avatar
Ignite 1
Level 2
ks_hitijingole
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 3
Boost 1
View profile

Avatar
Ignite 1
Level 2
ks_hitijingole
Level 2

Likes

3 likes

Total Posts

18 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 3
Boost 1
View profile
ks_hitijingole
Level 2

09-06-2021

Hi,

 

I have a component with multifiled (testAppIDs). The multifield data gets stored in form of nodes after Coral 3 migration (item0,item1 etc.). 

ks_hitijingole_0-1623251491719.png

 

Earlier before Coral 3 Migration Model class had a logic to use the JSON array. I want the model class to use the same logic as the impact might be huge. So now after Coral 3 migration, as I cannot pass testAppIDs using @ValueMapValue , I am trying to create the same String[] by iterating through child node of testAppIDs. 

ks_hitijingole_1-1623251856057.png

Can you help me understand how can I fetch property and value data from the item nodes and put it in testAppIds String []. Sample Data Expected to be stored in testAppIds ->  [{"tapID":"TAP_10050"}, {"tapID":"TAP_10049"}, {"tapID":"TAP_10050"}]

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile
davidjgonzalezzzz
Level 5

09-06-2021

// using gson JsonObject

List<String> tapIds = new ArrayList<String>();

for(Resource item : items.getChildren()) {
     JsonObject itemObject = new JsonObject();
     itemObject.addProperty("tapID", item.getValueMap().get("tapID", String.class));
     tapIds.add(itemObject.toString());
}

return tapIds.toArray(new String[tapIds.size()]);

Should be able to do something like that? i wrote that in the comment field itself, so there might be some syntax issues ... but should give you the gist. You can do it more concisely in a stream, but that's just style.

Answers (0)