Parse json file with ironpython 2.5
Question: I am using IronPython 2.5 (inside TIBCO Spotfire) and would like to parse a
json file.

The json library is not available in this version of IronPython. simplejson
doesn't work either. Is there another library i can use for this? It can be
.Net or Python, doesn't matter.

Thanks in advance!


Answer: I have also done it with `JavaScriptSerializer`. As follows:

    
    
    peopleJson = '''[
        {"name":"Jon", "age": "29", canSing:false, favColors:["red", "white"]},
        {"name":"Lilly", "age": "55", "canSing": true}
    ]'''
    #convert json to string
    import clr
    clr.AddReference('System.Web.Extensions')
    from System.Web.Script.Serialization import JavaScriptSerializer
    people = JavaScriptSerializer().DeserializeObject(peopleJson)
    
    for person in people:
        # each line is a dictionary
        print person['name'] + ' ' + person['age']
    

The output is:

    
    
    Jon 29
    Lilly 55
    

