2
votes

Using Mule 3.3, I've got a Payload (which starts out as a JSON and I'm converting it to an Object using java.util.HashMap). I can access the variables just fine from a JDBC query using:

#[message.payload.AddJob.variable1]

How do I go about adding a new variable (say variable2), or modifying the value of an existing variable?

I've tried:

<message-properties-transformer doc:name="Message Properties">
    <add-message-property key="message.payload.AddJob.variable2" value="&quot;hello&quot;"/>
</message-properties-transformer>

Which had no effect.

I also tried a groovy Script (below) as suggested here: How to add additional data to a mule payload?, but it overwrites the entire payload with "hello", not just variable2.

payload['AddJob.variable2'] = 'hello'
1
I'm not sure what AddJob would be called. The JSON data Mule is receiving before transforming into an Object looks like this: {"AddJob":{"Variable1":12345,"Variable2":67890}} - Benjamin Bryan
Cool, that should be a map of maps then. - David Dossot

1 Answers

9
votes

What with:

<expression-transformer
            expression="#[message.payload.AddJob.variable2='hello';message.payload]" />

?