Forum

Message Boards Message Boards

Back

Short format of json response from finder?

Short format of json response from finder?
Answer
25 March 2020 3:44
Dear CREODIAS team,

I realize that the JSON response (search.json) of the finder queries have more (relevant) attributes than the equivalent XML response (search.atom). 
In particular, I am interested in the relativeOrbitNumber. However, the JSON response also has a huge volume of not so relevant attributes (e.g. keywords).
Is there a way to ask for a short version of a JSON response?

Guido Lemoine 
0 (0 Votes)

RE: Short format of json response from finder?
Answer
13 May 2020 5:57 as a reply to Guido Lemoine.
Hi Guido,

Sorry for late reply.
Have you tried "jq" for parsing JSON?

eg.
$ curl "https://finder.creodias.eu/resto/api/collections/Sentinel2/search.json?maxRecords=10&sortParam=startDate&sortOrder=descending&status=all&dataset=ESA-DATASET" | jq '.features[] | {"title": .properties.title, "relativeOrbitNumber": .properties.relativeOrbitNumber}' 

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed100  132k    0  132k    0     0   911k      0 --:--:-- --:--:-- --:--:--  911k

{
  "title": "S2B_MSI_NOBS__20200615T140045_20200615T141739_017110_000281",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T133715_20200615T134323_017110_000102",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T121644_20200615T121745_017109_000017",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T120350_20200615T120701_017109_000053",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T115633_20200615T115959_017109_000057",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T105025_20200615T105329_017108_000051",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T104416_20200615T104636_017108_000039",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T083553_20200615T090853_017107_000549",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T072155_20200615T072640_017106_000079",  "relativeOrbitNumber": 0}
{  "title": "S2B_MSI_NOBS__20200615T065615_20200615T071909_017106_000381",  "relativeOrbitNumber": 0}
or

curl ... | jq '[.features[] | {"title": .properties.title, "relativeOrbitNumber": .properties.relativeOrbitNumber}]'
    [  {    "title": "S2B_MSI_NOBS__20200615T140045_20200615T141739_017110_000281",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T133715_20200615T134323_017110_000102",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T121644_20200615T121745_017109_000017",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T120350_20200615T120701_017109_000053",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T115633_20200615T115959_017109_000057",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T105025_20200615T105329_017108_000051",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T104416_20200615T104636_017108_000039",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T083553_20200615T090853_017107_000549",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T072155_20200615T072640_017106_000079",    "relativeOrbitNumber": 0  }, 
{
    "title": "S2B_MSI_NOBS__20200615T065615_20200615T071909_017106_000381",    "relativeOrbitNumber": 0  }]


Regards,
Marcin
0 (0 Votes)

RE: Short format of json response from finder?
Answer
14 May 2020 10:38 as a reply to Marcin Gil.
Thanks Marcin.

I did not know jq, will have a look. 

I was looking for a way to reduce the total amount of data you need to get before parsing,
but the response of the finder RESTful service if actually lightning fast, so there is no real bottleneck.

With greetings,

Guido

0 (0 Votes)