Parse JSON response from a RESTful call

I am working in a class project to demo RESTful web service workflows. The idea is to use different web services available online: e.g Google Services...

I implemented a HTTP adapter to perform a GET to the Google Translation RESTful Web Service.
The URL is https://www.googleapis.com/language/translate/v2?key=%key%&q=%val%&sourc...

The response of this call is given as JSON only (No XML support), and the format is:
{
"data": {
"translations": [
{
"translatedText": "fleurs"
}
]
}
}

I need to implement a conversion task ( Similar than XPATH) where I can access the translatedText and assign this to output variable. Something like: textTransalated = data.translations[0].translatedText;

Any ideas of how to parse JSON outputs?

I appreciated any help on this.

Thanks,
Manuel Correa

Try the new JS adapter

Hi Manuel Correa,

very good question.

We have just added a new JavaScript (JS) adapter in the latest version of JOpera 2.5.4 which you can use to process the JSON data in the most convenient way.

To exchange data with your JavaScript snippets simply declare parameters in the corresponding program. They will become accessible as variables within your scripts. Incoming JSON objects are automatically parsed and transformed into JavaScript objects. Outgoing objects must be translated using .toSource() within your script as they are assigned to the variables corresponding to JOpera's output parameters.

Take a look at the treetaps.oml example to see how it can be used and let us know if you have any questions.

Best Regards,
JOpera Team

That solve the problem.

That solve the problem. Really nice addition.

I got it working with the new JS adapter.
Script:
translatedText = jsonTranslation.data.translations[0].translatedText;
Just in case somebody need it.

Thanks