Questions tagged [json]

JSON stands for JavaScript Object Notation. Use this tag for questions about the JSON format itself, and for questions on how to convert, manipulate and distribute JSON data.

JSON is an open standard format for data storage and data transmission using name-value pairs and arrays. JSON is based on JavaScript, and the format is both machine and human readable.

62 questions
29
votes
4 answers

Bash CLI remove quotes from output of a command

I am trying to load a JSON file using jq per here. It is quite straightforward and this works: $ cat ~/Downloads/json.txt | jq '.name' "web" However, I need to assign the output of this variable to a command. I tried to do this and this works: $…
edesz
  • 803
27
votes
4 answers

JSON Validator in Ubuntu 16.04

I am trying to get my hands on some JSON file validators. I came across jq but after running jq . file.json I only got JSON formatted output, not a validation of the JSON in my file. I want to know how I can check the syntax or validate JSON format…
16
votes
3 answers

In Windows Terminal running Ubuntu, how can I make the default directory be ~ (/home/jake) instead of / (root)?

I have both Windows Terminal and Ubuntu installed from the Microsoft Store inside of Windows 10 (I don't know if this is WSL Version 1 or Version 2. The wsl -l -v command failed.). My default directory is set to the right directory but it always…
6
votes
3 answers

"jsonlint: command not found", although jsonlint IS installed

I am interested in using jsonlint on commandline in my Ubuntu 16.04 OS. So I executed sudo apt-get install jsonlint and I got Reading package lists... Done Building dependency tree Reading state information... Done jsonlint is already the…
Shy
  • 235
4
votes
2 answers

How can I structure jq filters to return video and audio codec information from ffprobe?

In the interest of standardizing my video library I'm trying to find a way to quickly create a list of files that need to be converted. After looking at this question and its answer (and much googling) I think I have the basics figured out, but I'm…
4
votes
4 answers

Convert text file to CSV on shell

I would like to convert a text file into CSV format. Here is an excerpt from the…
4
votes
0 answers

Graphical folding editor for JSON?

The Ubuntu repositories come with the package xmlcopyeditor, which installs XML Copy Editor; a nice, graphical folding editor for the somewhat outdated XML data file format. I am looking for a similar graphical folding editor, but then for the…
Serge Stroobandt
  • 5,719
  • 1
  • 54
  • 59
4
votes
2 answers

How to read .json to output an specific number?

Hello I've been using this: curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" -o ~/.cache/weather.json to write a weather.json file in my cache folder. the output is this. the…
Wonky
  • 321
  • 1
  • 3
  • 12
4
votes
1 answer

How to send JSON as variable with bash curl?

I'm trying to send a POST request with curl, but I'd like to store the json data in a variable in order to resend it if an error occur. I used this code: jsonvariable="{"ora" : "value1", "temp" : "value2", "rh" : "value3", "lat" : "value4", "longi"…
yuki182
  • 43
4
votes
1 answer

Modifying Large JSON Files in Linux

I have a need to modify large JSON files that choke most editors (meaning: most editors will take a long time to open the file, and even after the file is loaded, the editor will become unresponsive while I'm attempting to make modifications). The…
Lonnie Best
  • 2,244
3
votes
4 answers

How to remove only the last forward slash in the field?

I have a json file where I need to remove the last forward slashes only. See the example: {"url":"http://example.com/vary/file/","originalUrl":"http://example.com/vary/file/","applications":[{.........}]} I just want the data to look like: …
3
votes
2 answers

How to know a JSON array is an empty array in bash?

I use this code to consume GitHub API and automate some tasks: curl --silent -H 'Authorization: token github_access_token' 'https://api.github.com/orgs/OrganizationName/repos?per_page=100' Sometimes I get this as the response: [ ] I want to know…
3
votes
1 answer

Firebase private key file as environment variable

I'm very new to Ubuntu and developing a project based on firebase firestore database. Trying to run services on ubuntu server 22.04. I can connect firestore database (in windows I can do this by using environment variables also) with a private key…
newbie
  • 151
  • 5
3
votes
1 answer

jq how to replace a clear text to a text variable

When I use commmand: jq -r '.balances[] | select(.asset=="BTC").free' wallet.json result: "4723846.89208129" When I use command: coin2=BTC jq -r '.balances[] | select(.asset=="$coin2").free' wallet.json result: nothing How to fix this error?…
NamPT
  • 41
3
votes
3 answers

How to set boolean value in curl command used bash script

I need set into variable true/false value and send him into json with curl command: name=$1 sx=$2 `curl -d '{"name":"'"$name"'", "sex":true}' -H "Content-Type: application/json" -X POST http://localhost:8080/setacc` Variable sx accepts the value…
1
2 3 4 5