Skip to content
Advertisement

Extract three values from JSON output

I am trying to get three specific values from within a JSON return. I can only figure out how to get ALL the information rather than specific pieces. Here’s the JSON output (note – the date 2021-08-13:2 is going to change every week but I need that value also the 710.0 will likely change, too):

JavaScript

What I need is the date (in this case 2021-08-13:2 and also the “ask” and “bid”.

Here’s the code I’ve got so far:

JavaScript

I tried things like contract_info = json_response[‘callExpDateMap’][0] thinking it’s list position 0 that would return the date but alas I’m stuck.

Thanks in advance for your help

Advertisement

Answer

Here’s a fragment based on your variable names that will find all of the ‘ask’ values:-

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement