AnsweredAssumed Answered

Need to count the fields and pass the corresponding value

Question asked by arijit.chandra573037 on Jul 5, 2018

PFB the incoming JSON request:

 

{
"activityNotesDetails": [
{
"name": "Arijit",
"class": 9,

"description":"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
},
{
"name": "Shiba",
"class": 10
}
]
}

 

activityNotesDetails is an array and it might contain at max 3 fields (name, class and description) as these fields are optional.

we need to count each fields and populate corresponding text values in an xml array and if value contains more than 100 fields then we need to populate next set of fields in different tag with counter increment value.PFB final response to understand the requirement more clearly:

 

XML response to populate:

 

<Root>
<item>
<number>1</number>
<text>name:Arijit</text>
</item>
<item>
<number>2</number>
<text>class:9</text>
</item>
<item>
<number>3</number>
<text>description:abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx</text>
</item>
<item>
<number>4</number>
<text>description:yz</text>
</item>
<item>
<number>5</number>
<text>name:Shiba</text>
</item>
<item>
<number>6</number>
<text>class:10</text>
</item>
</Root

 

Thanks,

Arijit Chandra

Outcomes