JSON: Difference between revisions

From OSSelot
Jump to navigation Jump to search
No edit summary
(Adapted to the REST interface)
Line 1: Line 1:
==Obtain curation data in JSON format==
==Obtain curation data in JSON format==
====Single version====
====Single version====
To obtain curation data of a single version of a software package, the following URL may be used:
To obtain curation data of a single version of a software package in JSON format, the following REST call may be used:
<nowiki>
<nowiki>
  http://osselot.org/json.php?<package>/version-<version>
  http://www.osselot.org:3262/json/<package>/<version>
</nowiki>
</nowiki>
such as in a wget command
such as in a wget command
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
wget -qO - http://osselot.org/json.php?angular/version-15.2.2
wget -qO - http://www.osselot.org:3262/json/angular/15.2.2
</syntaxhighlight>
</syntaxhighlight>


Line 13: Line 13:
The command to obtain JSON formatted data of all available versions of a software package is very similar to the above except that the "version" part is not given such as
The command to obtain JSON formatted data of all available versions of a software package is very similar to the above except that the "version" part is not given such as
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
wget -qO - http://osselot.org/json.php?angular
wget -qO - http://wwww.osselot.org:3262/json/angular
</syntaxhighlight>
</syntaxhighlight>


====Format JSON file in browser====
====Format JSON file in browser====
If your browser supports display of JSON data either natively or after having installed an appropriate extension, you may immediately browse to the URL such as
If your browser supports display of JSON data either natively or after having installed an appropriate extension, you may immediately browse to the JSON data such as
<html>
<html>
<script>
<a href="http://www.osselot.org:3262/json/angular/15.2.2">angular version 15.2.2</a>
 
</html>
function loadJSON(anchor, url)
or even
{
<html>
  if (window.XMLHttpRequest)
<a href="http://www.osselot.org:3262/json/angular">all curated versions of angular</a>.
    xmlhttp = new XMLHttpRequest();
</html>
  else
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");


  xmlhttp.onreadystatechange = (function() {
<i>(Please note that the above browser commands, particularly the second, may take a long time to render.)</i>
    if (xmlhttp.readyState == 4) {
      if (xmlhttp.status == 200) {
        response = xmlhttp.responseText;
        name = url.split("?")[1].replace("/", "-") + ".json";
        var blob = new File([response], name, {"type": "application/json"});
        var a = document.createElement("a");
        a.href = URL.createObjectURL(blob);
        anchor.parentElement.insertBefore(a, anchor);
        a.click();
        a.remove();
      }
    }
  });
  xmlhttp.open('GET', url, true);
  xmlhttp.send();
}
 
</script>
<a onclick="loadJSON(this, 'https://www.osselot.org/json.php?angular/version-15.2.2');">https://www.osselot.org/json.php?angular/version-15.2.2</a>
</html>

Revision as of 23:15, 26 July 2023

Obtain curation data in JSON format

Single version

To obtain curation data of a single version of a software package in JSON format, the following REST call may be used: http://www.osselot.org:3262/json/<package>/<version> such as in a wget command

wget -qO - http://www.osselot.org:3262/json/angular/15.2.2

All available versions of a software package

The command to obtain JSON formatted data of all available versions of a software package is very similar to the above except that the "version" part is not given such as

wget -qO - http://wwww.osselot.org:3262/json/angular

Format JSON file in browser

If your browser supports display of JSON data either natively or after having installed an appropriate extension, you may immediately browse to the JSON data such as angular version 15.2.2 or even all curated versions of angular.

(Please note that the above browser commands, particularly the second, may take a long time to render.)