I have a Dynamodb records example
{
"cDate":"2024-03-04",
"myList":[
{
"M" : {
"rt":{"N":"1.06"},
"sDt":{"S":"2024-03-01"},
"c":{"S":"ABC"},
"t":{"S":"BCD"}
}
},
{
"M" : {
"rt":{"N":"0.96"},
"sDt":{"S":"2024-03-01"},
"c":{"S":"CDE"},
"t":{"S":"DEF"}
}
}
],
"type":"inter"
}
while some records have structure
{
"cDate":"2024-03-04",
"myList":[
{
"rt":"1.06",
"sDt":"2024-03-01",
"c":"ABC",
"t":"BCD"
},
{
"rt":"0.96",
"sDt":"2024-03-01",
"c":"CDE",
"t":"DEF"
}
],
"type":"inter"
}
As the records structure is not similar I want to standardise it. I want to read all the records from this table, I am trying as
class MyTable {
String cDate;
String type;
List<MyList> myList;
}
class MyList {
String rt;
String sDt;
String c;
String t;
}
QueryConditional queryConditional = QueryConditional.sortGreaterThanOrEqualTo(qc-> qc.partionValue("inter").sortValue("2024-03-04");
final DynamoDbIndex<MyTable> indexResult = table.index("indexName");
final SdkIterable<Page<MyTable>> pageResult = indexResult.query (q-> q.queryConditional(queryConditional)
.attributesToProject("cDate", "type")
.addNestedAttributesToProject( NestedAttributeName.create("myList","M")
)));
List<MyTable> collectedItems = new ArrayList<>();
pageResult.stream().forEach(page-> page.items().stream().forEach(mt-> {
log.info(mt.toString());
collectedItems.add(mt);
}));
using the above code I am able to print
MyTable[cDate=2024-03-04, type=inter, myList=null]
Please help me fetch the values for myList