Given a JSON file, arguments.json
:
{"dagger": true, "version": false, "nether_strike": true, "greater_bash": "5", "FILE": "ancientscroll.txt", "empower_haste": "1", "help": false}
When calling reading the variables as such:
#!/bin/bash dagger=$(cat arguments.json | jq '.["dagger"]') greater_bash =$(cat arguments.json | jq '.["greater_bash"]') echo $dagger echo $greater_bash
[out]:
true "5"
The variable contains the quotation marks ""
.
How to remove the quotes when reading a variable in jq?
I could use sed
to strip the quotes as such:
greater_bash =$(cat arguments.json | jq '.["greater_bash"]' | sed -e 's/^"//' -e 's/"$//') echo $greater_bash
[out]:
5
Related Posts:
- Select objects based on value of variable in object using jq
- How to grep for case insensitive string in a file?
- How to install JQ on Mac on the command line?
- “sed” command in bash
- How to remove double-quotes in jq output for parsing json files in bash?
- How to sort a json file by keys and values of those keys in jq
- Can comments be used in JSON?
- How do I pause my shell script for a second before continuing?
- Angular: ‘Cannot find a differ supporting object ‘[object Object]’ of type ‘object’. NgFor only supports binding to Iterables such as Arrays’
- How do I split a string on a delimiter in Bash?
- In the shell, what does ” 2>&1 ” mean?
- Use of PUT vs PATCH methods in REST API real life scenarios
- Can comments be used in JSON?
- How do I use a regex in a shell script?
- An example of how to use getopts in bash
- How to delete from a text file, all lines that contain a specific string?
- Multi-line string with extra space (preserved indentation)
- What is the difference between YAML and JSON?
- Loop through an array of strings in Bash?
- ‘\r’: command not found – .bashrc / .bash_profile [duplicate]
- How do I iterate over a range of numbers defined by variables in Bash?
- Fastest JSON reader/writer for C++
- Representing null in JSON
- Are multi-line strings allowed in JSON?
- What does “-ne” mean in bash?
- How can I declare and use Boolean variables in a shell script?
- How to reload .bash_profile from the command line?
- How to generate random number in Bash?
- Replace one substring for another string in shell script
- Parsing JSON with Unix tools
- How to check if a variable is set in Bash?
- Remove properties from objects (JavaScript)
- “[ ]” vs. “[[ ]]” in Bash shell
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Python/Json:Expecting property name enclosed in double quotes
- Given two directory trees, how can I find out which files differ by content?
- Why do i need `typings.json` file in an Angular 2 project?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- How do I set a variable to the output of a command in Bash?
- Is there a TRY CATCH command in Bash
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Javascript Object push() function
- How to convert a string to lower case in Bash?
- Is there a “goto” statement in bash?
- How do you represent a JSON array of strings?
- RE error: illegal byte sequence on Mac OS X
- Using Wikipedia API on custom wikis like Bulbapedia
- Sorting data based on second column of a file
- Using SED with wildcard
- How to import a JSON file in ECMAScript 6?
- zip error – Nothing to do
- UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0x80 in position 3131: invalid start byte
- How to sort an array in Bash
- How to split one string into multiple strings separated by at least one space in bash shell?
- XSLT equivalent for JSON
- How can I do a recursive find/replace of a string with awk or sed?
- How to use sed to extract substring
- Is there a query language for JSON?
- An error occurred while installing json (1.8.1), and Bundler cannot continue – Rails
- sed whole word search and replace
- Integer expression expected error in shell script
- Error when using ‘sed’ with ‘find’ command on OS X: “invalid command code .”
- What are the Oembed Links For?
- Get Image URL instead of Attachment Id in Rest API
- WP API returning SQL results as strings, rather than numbers
- What is /wp-json?
- Import JSON feed to WordPress
- Include custom post meta value in fetched JSON
- Importing JSON feed should the content be sanitized?
- WP REST API – Retrieve content from page
- wordpress API for android app
- WordPress JSON API returns normal site page in html. How do I get it to give me JSON?
- Create multiple posts with WP REST API at once
- Have WordPress generate a JSON of the content
- Adding JSON Structured Data to WordPress
- esc_attr() corrupts json values
- Cannot parse results from wp_remote_get
- Why is json_decode failing?
- WP REST API. Configuring JSON routes
- JSON API not showing full content
- Strange “lea” prefix on wp-json
- Retrieving a JSON feed of my posts and displaying thumbnails
- wp-json how to fetch image link?
- Received Updateing failed. not a valid JSON response. linked with _locale=user
- Automatically import content to wordpress from a json file
- JSON api oembed youtube
- Add binary or json animation to wordpress site
- Run hook in functions.php from page link
- How can cookie/session authentication be used in wp-json fetch request?
- I can’t get those posts from the wordpress to ionic
- Dynamic data table from external json feed
- return content section as json in wp rest api v1
- Control character encode after using jquery autocomplete
- Output JSON and no theme
- Get JSON from self hosted wordpress site
- WP REST API get all posts (or customs posts) for a React app
- How do i save this python code to text file.? [closed]
- What is the difference between double and single square brackets in bash?
- How to add a timestamp to bash script log?
- Error /wp-json/wp/v2/posts/ [closed]