i am wring the shell script as i am new. my query is i have json object like
{
"logo": {"name":"logo.png","type":"image\/jpeg","tmp_name":"C:\\xampp\\tmp\\php8B97.tmp","error":0,"size":110290},
"template":"template1",
"firstname":"a",
"lastname":"a",
"username":"a",
"password":"aa",
"email":"a",
"categoriesListArr":"{\"Women\":[\"All footwear\",\"All footwear\",\"All Clothing\",\"All Clothing\",\"All Watches\",\"All Watches\",\"All Sunglasses\",\"All Sunglasses\"],\"Men\":[\"All Mens Accessories\",\"All Bags,Belts And wallets\",\"All Fragrances\",\"All Grooming and wellness\"]}",
"aboutUs":"aa",
"contactUs":"78787878878787",
"deliveryInfo":"aa",
"privacyPolicy":"aa",
"t&d":"aa"
}
i extracted the categoriesListArr using jq filter as follows:
categories=`cat detail.json| jq '.categoriesListArr'`
detail.json is the name of the file. now categories is stringify object...i need to parse it and convert it into json object.
"{\"Women\":[\"All footwear\",\"All footwear\",\"All Clothing\",\"All Clothing\",\"All Watches\",\"All Watches\",\"All Sunglasses\",\"All Sunglasses\"],\"Men\":[\"All Mens Accessories\",\"All Bags,Belts And wallets\",\"All Fragrances\",\"All Grooming and wellness\"]}"
how i can convert it using jq filter
fromjson is your friend:
$ jq '.categoriesListArr | fromjson' detail.json
Or, if you want to retain the original structure:
$ jq '.categoriesListArr |= fromjson' detail.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With