I have a JDBC COnnector which retrieves values from the database and I have mapped them from object to JSON. Now I want to extract specific values from the json to flow variables. When I try to log #[message.payload], I get the full payload in the log which is in JSON format. However when I try to choose an attribute (eg. testattribute in json) #[message.payload.testattribute], I get mule expression error. How do I refer to the json values?
Once the payload is a JSON string, you can't extract anything from it anymore with an expression.
So either:
If your requirement is to get the values from json data you can use a simple MEL expression like
#[json:<name of the node>]
For example if you have an sample json data like this
{
"token" : 123,
"id" : 456,
"email" : "[email protected]",
"status" : "Success"
}
and if you want get the id from the data just use the below simple MEL.
#[json:'id']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With