Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 524

compare two json string failing while using jq [closed]

$
0
0

Hi I am using jq in my shell script to compare two json strings. the json string are present in two shellscript variable . the following is the code

function compareJson() {    local expectedJson="$1"    local actualJson="$2"    if diff <(echo "$expectedJson" | jq --sort-keys .) <(echo "$actualJson" | jq --sort-keys .) >/dev/null; then        echo "JSON data is equal."        echo "Test passed"    else        echo "JSON data is different."        echo "Test failed"        exit 1    fi}RESPONSE={"status":"All good as well"}CALLBACK_EXPECTED_RESPONSE_AS_STRING : {"status":"All good as well"}compareJson $CALLBACK_EXPECTED_RESPONSE_AS_STRING $RESPONSE 

however i am getting the following output when i call compareJson

$$ jq --sort-keys .$$ jq --sort-keys .jq: parse error: Unfinished string at EOF at line 2, column 0jq: parse error: Invalid numeric literal at line 2, column 0

I want to fix this error without making any changes to the compareJson file .

appreciate any helpthank you


Viewing all articles
Browse latest Browse all 524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>