Passing data for Curl Function to a Python program on Bash
Question: So I'm trying to extract data from the curl function as listed on this Asana
API. <https://asana.com/developers/api-reference/projects>. The problem is
that the data I receive looks like this

{"data":[{"id":"1000","name","first thing"},{"id":"1001","name","second
thing"}, {"id":"1002","name","third thing"}]}

This is a great dictionary organized really nicely, but I'm unable to actually
use it because bash doesn't recognize this as a dictionary. It is simply
reading it as a string. I'm very familiar with python, so I thought if I pass
it to a python program it will recognize it as a dictionary, but it doesn't.
Please help. All I need is to be able to establish the data as a dictionary
and array as it should be. After that I can work with it as I want.

This is what I have so far.

    
    
       READFILE=$(curl -u $KEY: https://app.asana.com/api/1.0/projects)
       echo $READFILE
    

if I try to do something like this, however,

    
    
      for dict in ${READFILE["data"]};
         do echo $dict
      echo ABC
      done
    

bash returns splits the data by white space, so it'll look like this

    
    
      {"data":[{"id":"1000","name","first
      ABC
      thing"},{"id":"1001","name","second
      ABC
      thing"},{"id":"1002","name","third
      ABC
      thing"}]}
      ABC
    

Similarly if I pass this to a external python script like this

    
    
      python work.py $READFILE
    

and I try to print like this

    
    
      import sys
      print(sys.argv);
    

I'll get

    
    
      {"data":[{"id":"1000","name","first
    

Help me get Python to receive the actual data structure, not just a string
split at whitespaces.


Answer: There is a [python api](https://github.com/Asana/python-asana) for asana so
you can so it all using python:

    
    
    # basic auth
    client = asana.Client.basic_auth('ASANA_API_KEY')
    
    # oauth 2 
    client = asana.Client.oauth(
    client_id='ASANA_CLIENT_ID',
    client_secret='ASANA_CLIENT_SECRET',
    redirect_uri='https://yourapp.com/auth/asana/callback'
    )
    

There are numerous examples in the link above.

