Questions tagged [json]

128 questions
18
votes
1 answer

Loop over Ansible variable array in Jinja2 template

when Ansible gathers facts about hosts, it for example gets all the mounts of the host: "ansible_mounts": [ { "block_available": 7800291, "block_size": 4096, "block_total": 8225358, …
ThatGuyOnTheNet
  • 193
  • 1
  • 1
  • 6
13
votes
3 answers

How get systemd status in json format?

I want to get service status details (Loaded, enabled, active, running, since, Main PID) in machine readable form and I know that systemd tools have --output=json option, but if I do: systemctl status servicename --output=json --plain I see…
Stanislav Ivanov
  • 383
  • 1
  • 3
  • 10
9
votes
2 answers

Can I alias all directory requests to a single file in nginx?

I'm trying to figure out how to take all requests made to a particular directory and return a json string without a redirect, in nginx. Example: curl -i http://example.com/api/call1/ Expected result: HTTP/1.1 200 OK Accept-Ranges:…
user749618
  • 193
  • 1
  • 6
7
votes
1 answer

How to tell jq to print the content of two keys for each instance returned by aws ec2 cli

running aws ec2 describe-instances will return a json text similar to the following: { "Reservations": [ { "Instances": [ "PublicDnsName": "ec2..." "VpcId": "vpc-...", …
Michael Martinez
  • 2,645
  • 3
  • 24
  • 35
7
votes
4 answers

What's wrong with this HTTP POST request?

I'm trying to fuzz a server using the Sulley fuzzing framework. I observe the following stream in Wireshark. The error talks about a problem with JSON parsing, however, when I try the same HTTP POST request using Google Chrome's Postman extension,…
bigboy
  • 101
  • 1
  • 1
  • 4
6
votes
2 answers

Manipulate JSON in bash

I have a JSON file I need to update a particular value. { "Comment": "comment", "test": { "enabled": true }, "enabled": true, "otherStuff": blah, "otherStuff2": blah, "otherStuff3": blah, } I would like to change the value of the…
Bastien974
  • 1,896
  • 12
  • 44
  • 62
5
votes
2 answers

How to escape or remove double quotes in rsyslog template

I want rsyslog to write log messages in JSON format, which requires to use double-quotes (") around strings. Problem is that values sometime include double-quotes themselves, and those need to be escaped - but I can't figure out how to do…
Evgeny
  • 599
  • 5
  • 10
4
votes
2 answers

awcli query option for multiple filter expressions

Given the output of aws ec2 describe instances I am trying to display objects that have no Platform value and DO have a VpcId value. So far I have come up with this: aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"…
Roderick Day
  • 51
  • 1
  • 5
4
votes
2 answers

IOException: Socket read failed using Apache 2, mod_jk and Tomcat over AJP

I am getting the following Exception from time to time when my users are connecting with their Android devices to out JSON Rest Service: java.io.IOException: Socket read failed at…
Thomas Einwaller
  • 288
  • 1
  • 3
  • 12
4
votes
1 answer

nginx loggin $request_body produces weird encoding

I have an nginx server that logs POST $request_body to a file. When I post json to the server, it replaces quotes (") with \x22. My config looks like this server { server_name myServer; listen 8180; log_format logMyServer…
4
votes
2 answers

How do I Generate a Bearer Token for cURL to Get Thru IAP (GCP)?

I need to cURL a web app hosted behind IAP on GCP. Normally, users log in through IAP and use the web app, but I need to run some cURL commands (interactive and non-interactive) that hit the web app URLs (for example: …
4
votes
1 answer

Building List of JSON Objects in Ansible

I'm trying to build an array/list of JSON objects in Ansible. My playbook is called by specifying --extra-vars "userids=123456,654321". I then try to build the list with the following. "TBD" is just a place-holder. I will fill those values with…
JScott
  • 43
  • 1
  • 1
  • 3
3
votes
1 answer

jq sort by date (iso 8601)

I try to sort json by date (field CreationTimeUTC) in iso 8601 format with jq 1.5. I found this post, but that return : 'Cannot index boolean with string "CreationTimeUTC"' jq '.Entities.BackupJobSessions.BackupJobSessions[] |…
user5525652
  • 157
  • 1
  • 4
  • 14
3
votes
1 answer

jq : Get values from children array and display on parent array

I try to get theses value : "VmDisplayName, CreationTimeUTC, EndTimeUTC, Reason, Result, State, TotalSize, BackupServerReference, BackupJobSessionReference" from this json : { "JobSessionUid":…
user5525652
  • 157
  • 1
  • 4
  • 14
3
votes
1 answer

How to escape only quotes in haproxy log format

I am capturing the user-agent using: http-request capture req.hdr(User-Agent) len 192 And then trying to create a custom JSON log format like this: log-format '{"User-Agent":%{+Q,+E}[capture.req.hdr(0)]}' It works but when a User Agent includes…
nbari
  • 558
  • 1
  • 9
  • 28
1
2 3
8 9