All content on this Wiki is non-binding and any individual opinions expressed should not be considered indicative of the policies or positions of CDISC or any other organization.
Page tree
Skip to end of metadata
Go to start of metadata

We will be adding code snippets in other languages.

Introduction

In Getting Started: Understanding the Response, we reviewed the basic structure of a JSON output and hypermedia link. In this article, we will share a few options to programmatically consume the JSON response from /mdr/products/Terminology.

Python

JSON is native to Python. Working with CDISC Library's JSON outputs is fairly straighforward. This code show how to iterate through all the hypermedia links and simply dumping out the content:A sample output:

/mdr/ct/packages/adamct-2014-09-26 is a Terminology link for ADaM Controlled Terminology Package 19 Effective 2014-09-26
/mdr/ct/packages/adamct-2015-12-18 is a Terminology link for ADaM Controlled Terminology Package 24 Effective 2015-12-18
...
/mdr/ct/packages/sendct-2018-12-21 is a Terminology link for SEND Controlled Terminology Package 36 Effective 2018-12-21

JSONPath

Another way is to use JSONPath. JSONPath is very similar to XPath (for XML) in many ways that allow you to query a JSON structure. The expression to obtain all the hrefs from the output:

$._links.packages.[href]

This is an excerpt of the JSONPath result:

[
  "/mdr/ct/packages/adamct-2014-09-26",
  "/mdr/ct/packages/adamct-2015-12-18",
  ...
  "/mdr/ct/packages/sendct-2018-12-21"
]

Further Readings

JSONPath Reference. Smartbear. https://support.smartbear.com/readyapi/docs/testing/jsonpath-reference.html