Avatar of condor888
condor888
 asked on

use shell script to parse json returned by a restful service

I have a Restful web service with a URL like "http://myhost:5000/getname" to return a JSON string like this:
{"firstName": "john", "lastName": "doe"}

Open in new window

.

Now that I need to use Linux shell to call the web service and parse the returned JSON string to get the first name and last name. They need to be stored into two variebles and printed out.

Please use out-of-box shell scripting. Don't use any utilities that need to be installed separately.

I am new to shell scripting, so would some one please kindly share your thoughts? Thanks!
Shell ScriptingOperating SystemsLinuxWeb Services

Avatar of undefined
Last Comment
condor888

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
woolmilkporc

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
condor888

ASKER
Thanks, woolmilkporc. It works. However, I don't understand some of the details. So is there a good resource that I can resort to in order to understand more about shell scripting? Thanks!
woolmilkporc

Here is a rather good bash guide/tutorial:
http://www.bash.academy/
A comprehensive list of tutorials available on the web:
http://wiki.bash-hackers.org/scripting/tutoriallist
Finally, this is the complete bash Reference Manual:
https://www.gnu.org/software/bash/manual/bash.html

As for "awk", which is kind of a languange on its own:
A tutorial (one of many out there): http://www.grymoire.com/Unix/Awk.html
The user's Guide: https://www.gnu.org/software/gawk/manual/gawk.html

I'm sure you'll find tons of other resources by searching the web.
Have fun and success!

wmp
condor888

ASKER
Ok, I will check them out. Thank you again for providing good learning resources.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
Shalom Carmel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
condor888

ASKER
Thanks for the solutions. It helped a lot!