Skip to main content
Rizwanul Shaikh 님이 #MuleSoft DataWeave에 질문했습니다

I am also stuck in this can anyone please help

 

var a= { "id":"1" , "cpoService":"finance", "name": "madan" }

 

var b= [

{ "id": 0, "name": "John" },

{ "id": 2, "name": "Jane" },

{ "id": 1, "name": "Bob" }

]

 

I need to update the var b obj with var a obj where id is matching on same index location where id= 1 is in var b.

 

@Manish Yadav​ 

@Shyam Raj Prasad​ 

@Anurag Sharma​ 

답변 4개
  1. 2023년 11월 9일 오후 5:58

    Hi @Rizwan Shaikh​ try the below dw :

    %dw 2.0

    var a = {

    "id": "1",

    "cpoService": "finance",

    "name": "madan"

    }

    var b = [

    {

    "id": 0,

    "name": "John"

    },

    {

    "id": 1,

    "name": "Jane"

    },

    {

    "id": 2,

    "name": "Bob"

    }

    ]

     

    output application/json

     

    var x = a.id as Number

    ---

    if(b[x].id == x) ((b - b[x]) << a) orderBy $.id else b

    1. a.id matched with index of b and b.id , so its replaced with a.Hi @Rizwan Shaikh​ try the below dw :%dw 2.

     

    1. a.id is not matched with index of b and b.id , so b is not changed .

    image