Python Forum

Full Version: Parse BytesIO data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I am new to Python and am writing some scripts for Jenkins.
I needed to get a Jenkins crumb which I have managed to do
The value received is
b'{"_class":"hudson.security.csrf.DefaultCrumbIssuer","crumb":"90fd32d5d18a2e84c9ec443fabd9800d4bfd9e22c9bdf29624c5be8b09a49a06","crumbRequestField":"Jenkins-Crumb"}'

My question is how do I access the value for "crumb"

Thanks
Looks like JSON, so parse it into a Python dictionary using the json module.
How are you getting the bytes object in? It might be a bit easier to read the data directly as JSON.

But if you had to get it as bytes, you could decode() it to a str, and then read that into JSON (json.loads()) and can then pull the pieces out.