Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse BytesIO data
#1
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
Reply
#2
Looks like JSON, so parse it into a Python dictionary using the json module.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to parse data fakka 2 1,464 Sep-22-2021, 10:50 PM
Last Post: bowlofred
  command line input (arg parse) and data exchange Simba 7 4,242 Dec-06-2019, 11:58 PM
Last Post: Simba
  Read csv file, parse data, and store in a dictionary markellefultz20 4 4,485 Nov-26-2019, 03:33 PM
Last Post: DeaD_EyE
  Parse data from xml file klllmmm 9 9,265 Jun-25-2019, 05:14 PM
Last Post: heiner55
  Parse the data in XML metadata field klllmmm 2 3,206 Jun-19-2019, 04:24 PM
Last Post: klllmmm
  Parse Binary Data File and convert Epoch Time drdevereaux 1 3,119 May-16-2019, 01:56 AM
Last Post: Larz60+
  How to parse the data in python sandy 10 5,081 Jan-15-2019, 05:50 PM
Last Post: sandy
  how to parse multipart/form-data for xls or jpeg stream into python code and store v71017 0 3,272 Mar-20-2018, 01:09 PM
Last Post: v71017

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020