I created the json from a python script, and here is the code what I wrote to get the json data:
import requests
import json
import ConfigParser
url = "xxx"
payload = "items.find({ \"repo\": {\"$match\" : \"nswps-*\"}}).include(\"name\",\"repo\",\"path\")\r\n"
headers = {
'Content-Type': "text/plain",
'Authorization': "Basic xxxxxxxxx",
'Accept': "*/*",
'Cache-Control': "no-cache",
'Host': "xxxxxx.com",
'accept-encoding': "gzip, deflate",
'content-length': "77",
'Connection': "keep-alive",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
the above code gives me the json file which is a huge file of multiple objects. Due to some limitation in artifactory I am unable to get the repos starting with nswps but rather the result is all the repository names. The json file has data like this:
"repo" : "npm-remote-cache",
"path" : "zrender/-",
"name" : "zrender-4.0.7.tgz"
},{
"repo" : "npm-remote-cache",
"path" : "ztree/-",
"name" : "ztree-3.5.24.tgz"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "manifest.json"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4"
},{
.........
Now I need to create a python script which fetches out the objects in which only the object that has value of nswps , lets say from the above json I need data like this:
{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "manifest.json"
},{
"repo" : "nswps-docker-inprogress-local",
"path" : "ace/core/latest",
"name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4"
}