my json file looks something like this
[{"product":"Apple","id":"2134"},{"product":"Mango","id":"4567"}]
I want to grep/sed/awk 'id' for given 'product'.
Output:
Enter product : Apple
Your product id is : 2134
Use a JSON aware tool. Perl has the JSON library:
#!/usr/bin/perl
use warnings;
use strict;
use JSON;
my $json = '[{"product":"Apple","id":"2134"},{"product":"Mango","id":"4567"}]';
print 'Enter product: ';
chomp( my $product = <> );
print 'Your product id is: ', 
    (grep $_->{product} eq 'Apple', @{ from_json($json) })[0]{id}, "\n";
perl -MJSON -e 'print map { $_ -> {id} } grep { $_ -> {product} eq "Apple" } @{decode_json( do { local $/; <> } )};'  - if you really must use shell. But honestly? perl can do everything a shell script can, and SO MUCH more.
                
                Use a json parser, not sed/grep/awk.
Using Python json module:
#!/usr/bin/env python2
import json
with open('file.json') as f:
    f_json = json.load(f)
    print 'Enter product : ' + f_json[0]['product'] + '\nYour product id is : ' + f_json[0]['id']
Output:
Enter product : Apple
Your product id is : 2134
I created a file called json that looks like this:
[{"product":"Apple","id":"2134"},{"product":"Mango","id":"4567"},{"product":"Pear","id":"1111"},{"product":"Banana","id":"2222"}]
Then I run this on the command line:
 cat json | sed -e 's/.\?{"product"\:\"\([^\"]\+\)\","id"\:\"\([[:digit:]]\+\)[^}]}\+.\?/Enter Product : \1\nYour Product id is : \2\n/mgi'
The output is this:
Enter Product : Apple
Your Product id is : 2134
Enter Product : Mango
Your Product id is : 4567
Enter Product : Pear
Your Product id is : 1111
Enter Product : Banana
Your Product id is : 2222
sed is clumsy, but here is what I could get -
sed  's/.*\(Apple\)[^:]*:"\([0-9]*\)".*/Enter product ID: \1\nYour  product ID is: \2/' 3
Enter product ID: Apple
Your product ID is: 2134
sed  's/.*\(Mango\)[^:]*:"\([0-9]*\)".*/Enter product ID: \1\nYour product ID is: \2/' 3
Enter product ID: Mango
Your product ID is: 4567
Edited based on latest input which is slightly different
./prod.sed Apple
Enter product ID: Apple
Your product ID is: 1234
./prod.sed Mango
Enter product ID: Mango
Your product ID is: 12345
prod.sed (use 3rd line for publishName)
#sed  's/.*product_id":"\(Apple\).*"productBuildId":"\([0-9]*\)".*/Enter product ID: \1\nYour product ID is: \2/' data
sed  's/.*product_id":"\('"$1"'\).*"productBuildId":"\([0-9]*\)".*/Enter product ID: \1\nYour product ID is: \2/' data
sed  's/.*product_id":"\('"$1"'\)","publishName":"\([^"]*\)".*/Enter product ID: \1\nYour publish ID is: \2/' data
explanation : substitute the string <anything> Mango <anything other than :> : <number> with -> Your product ID is: Mango <next line> 
Your product ID is : <the number we got> 
 \1 and \2 save the matched expression in \(..\) for later use.
Given a product name in $name, the ID of that product could be parsed out using jq like so:
jq -r --arg name "$name" '.[] | select(.product == $name).id' file.json
Example:
$ cat file.json
[{"product":"Apple","id":"2134"},{"product":"Mango","id":"4567"}]
$ name=Apple
$ jq -r --arg name "$name" '.[] | select(.product == $name).id' file.json
2134
Given your input, the following sed command ...
sed -e 's/[}"]*\(.\)[{"]*/\1/g;y/,/\n/' <your_input
...will write to output...
[product:Apple
id:2134
product:Mango
id:4567]
...probably you can take it from there.
jq