Now that's great and all, but what can Orchestrator help us do with it? Well with the addition of a couple of activities - "Convert XML to JSON" and "Convert JSON to XML" it all becomes quite easy! In my development with Orchestrator I have found using XPATH queries and trying to stay in the XML format is best for ease of use and for the product in general. XPATH query is a wonderful tool for pulling data out of XML based messages and is highly useful(and near a requirement) for developing strong automations with web service calls. The great Orchestrator development team has almost made it trivial for you to be able to work with both XML and JSON based web services. The eaiest case is to receive JSON back from a web call and then pass it into a "Convert JSON to XML" activity. The output XML will be a nicely and neatly formated piece of XML that you can easily do an xpath query from. For example
"title": "example glossary",
"GlossTerm": "Standard Generalized Markup Language",
"Abbrev": "ISO 8879:1986",
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
Will convert to XML:
<GlossTerm>Standard Generalized Markup Language</GlossTerm>
<para>A meta-markup language, used to create markup languages such as DocBook.</para>
(Sorry about the formatting)
Now doing XPATH queries on this xml is almost as trivial. If I want to pull out the Abbreviation, just XPATH Query it using "//Abbrev". (as an example). Before these activities you would have had to do string and regular expression work throughout a JSON response and that would have not been too pretty!
While this session is a short and sweet one, I could not go on without a video! So I have a quick (less than 10 minute) video on me using the JSON and XML conversion activities and running XPATH against it. (using the same demo JSON as above)
I hope after watching this you will feel confident in using JSON based web services in your automations. Please feel free to post any comments/questions/etc in the blog or send me an email.
Onto the video!!!
Shaun's Weekly Q/A
No questions this week! Hopefully we'll get some in to answer for next week!
Ever week I will pick a handful of questions from you, the reading CPO public, to answer in this part of the blog. Please post comments/questions below. I will no longer be using the external e-mail from previous blogs.
Please also let me know if you like the format of this blog and what else you would like to see/know about. Feel free to give any ideas as to future blog posts, etc and I will be happy to post them. I hope to do more how-tos, best practices, tips, tricks, and hopefully some interviews of the important people behind the scenes of CPO.
WEEKLY AUTOMATION BLOG DISCLAIMER: As always, this is a blog and my (Shaun Roberts) thoughts on CPO, my thoughts on best practices, and my experiences with the product and customers. The above views are in no way representative of Cisco or any of it's partners, etc. None of these views, etc are supported and this is not a place to find standard product support. If you need standard product support please do so via the current call in numbers on Cisco.com or email firstname.lastname@example.org
Thanks to all for reading and happy automating!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.