我从邮递员发送JSON对象,然后我的应用程序将此JSON转换为所需的格式(再次为JSON)并发送到服务器。
我传递了邮递员提供的accountid和角色数组。在第二个JSON中,我想动态读取并传递第二个JSON中的值
邮递员的JSON(第一个JSON)
{
"firstName":"holl",
"lastName":"land",
"emailAddress":"biz@foo.com",
"userName":"savapa",
"roles" :
[
***//I pass an array of accountid and roles***
{
"accountid" : "Acc444",
"role" : "Admin"
},
{
"accountid" : "Footballer",
"role" : "Non Admin"
}
]
}
**Object passed to server ( second JSON)**
createUserRequest: {
user: {
firstName: Request.firstName,
lastName: Request.lastName,
emailAddress: Request.emailAddress,
userName:Request.userName,
orgRolesList:{
for( i in Request.roles ){
***// I tried this to loop over array of accountid and roles passed***
orgRoles:[
{
organization:{
primaryKeys:{
name:Request.roles[i].accountid
}
},
roles:{
role:{
primaryKeys:{
name:Request.roles[i].role
}
}
}
}