json

How can I put integer as an argument in jq?

人盡茶涼 提交于 2021-02-16 16:14:30
问题 I have been trying to use jq to parse a json file returned from the aws cli, but I'm stuck with the problem of referencing an array using the index number. I need to do this because I want to export a text file describing the security groups in a specific format, including all the inbound and outbound rules. for (( i=1; i<=groupCount; i++ )) ; do echo $i echo $(echo "$input" | jq --arg i $i '.SecurityGroups[$i]') done This returns an error: 1 jq: error (at <stdin>:189): Cannot index array

Ruby getting deeply nested JSON API data

断了今生、忘了曾经 提交于 2021-02-16 16:11:17
问题 I have a rails app which gets a response from World Weather Online API. I'm using the rest-client gem and the response is in JSON format. I parse the response using: parsed_response = JSON.parse(response) Where parsed_response is obviously a hash. The data I need are strings inside a hash inside an array inside a hash inside another array inside another hash inside another hash. The inner-most nested hashes are inside ["hourly"] , an array of 8 hashes, each with 20 keys, possessing string

TCL - Parse JSON to hash/array

帅比萌擦擦* 提交于 2021-02-16 15:36:06
问题 I'm new in TCL, I have an JSON string, and I want to parse it to something I can use it easily like hash/ array which similar like in Perl or Java to loop the data and print it. But I've found many sources to help me, but it is very less and still couldn't get it. And I try something like this: #!/usr/bin/tclsh proc dict2json {dictVal} { # XXX: Currently this API isn't symmetrical, as to create proper # XXX: JSON text requires type knowledge of the input data set json "" dict for {key val}

FileNotFoundError but file exists

孤街浪徒 提交于 2021-02-16 15:33:05
问题 I am creating a Python application that imports many JSON files. The files are in the same folder as the python script's location. Before I moved the entire folder someplace else, the files imported perfectly. Since the script creates a files if none exists, it keeps creating the file in the home directory while ignoring the one in the same folder as it is in. When I specify an absolute path (code below): startT= time() with open('~/Documents/CincoMinutos-master/settings.json', 'a+') as f: f

FileNotFoundError but file exists

旧巷老猫 提交于 2021-02-16 15:33:02
问题 I am creating a Python application that imports many JSON files. The files are in the same folder as the python script's location. Before I moved the entire folder someplace else, the files imported perfectly. Since the script creates a files if none exists, it keeps creating the file in the home directory while ignoring the one in the same folder as it is in. When I specify an absolute path (code below): startT= time() with open('~/Documents/CincoMinutos-master/settings.json', 'a+') as f: f

How to keep one level of object and extract one of its sub-key only?

老子叫甜甜 提交于 2021-02-16 14:58:05
问题 I'm playing a bit with terraform state json output and want to transform it a bit. Given that input issued from terraform: { "cost": { "sensitive": false, "value": "123" }, "test_id": { "sensitive": false, "value": "6610758455459338306" } } How do i convert it to something usefull for my application like bellow: { "cost": "123", "test_id": "6610758455459338306" } I tried to play with from_entries , with_entries but i'm a complete noob at it 回答1: You're looking for map_values. It works just

I need to extract Data from a single line of json-data which is inbetween two variables (Powershell)

大城市里の小女人 提交于 2021-02-16 14:49:27
问题 I need to extract Data from a single line of json-data which is inbetween two variables (Powershell) my Variables: in front of Data: DeviceAddresses":[{"Id": after Data: ," I tried this, but there needs to be some error because of all the special characters I'm using: $devicepattern = {DeviceAddresses":[{"Id":{.*?},"} #$deviceid = [regex]::match($changeduserdata, $devicepattern).Groups[1].Value #$deviceid 回答1: As you've found, some character literals can't be used as-is in a regex pattern

JSON example confusing me - about JSON.parse, JSON.stringify, localStorage.setItem and localStorage.getItem

怎甘沉沦 提交于 2021-02-16 13:53:31
问题 I'm just starting to learn JSON and W3schools isn't very good at explaining what each line does. I can sort of figure out what some of them mean, but I'd like to figure it out completely. // Storing data: 1. myObj = {name: "John", age: 31, city: "New York"}; 2. myJSON = JSON.stringify(myObj); 3. localStorage.setItem("testJSON", myJSON); // Retrieving data: 4. text = localStorage.getItem("testJSON"); 5. obj = JSON.parse(text); 6. document.getElementById("demo").innerHTML = obj.name; So I know

“invalid type: map, expected a sequence” when deserializing a nested JSON structure with Serde

点点圈 提交于 2021-02-16 10:49:30
问题 I am trying to poll the GitHub API for issues and print them out. To do so, I need to deserialize a nested JSON structure that I receive from a cURL GET request. I am trying to get the url for all the objects in the items array: { "total_count": 4905, "incomplete_results": false, "items": [ { "url": "https://api.github.com/repos/servo/saltfs/issues/789", "repository_url": "https://api.github.com/repos/servo/saltfs", "labels_url": "https://api.github.com/repos/servo/saltfs/issues/789/labels{

“invalid type: map, expected a sequence” when deserializing a nested JSON structure with Serde

左心房为你撑大大i 提交于 2021-02-16 10:48:10
问题 I am trying to poll the GitHub API for issues and print them out. To do so, I need to deserialize a nested JSON structure that I receive from a cURL GET request. I am trying to get the url for all the objects in the items array: { "total_count": 4905, "incomplete_results": false, "items": [ { "url": "https://api.github.com/repos/servo/saltfs/issues/789", "repository_url": "https://api.github.com/repos/servo/saltfs", "labels_url": "https://api.github.com/repos/servo/saltfs/issues/789/labels{