Reading records from file

In a text file I have several records delimited by paragraphs. For example:

{name:“Bob”,age:45}
{name:“John”,age:32}

When I read this file using the following code:


set theRecords to (read (choose file))

all of the quotes are escaped with back slashes. i.e. theRecords =

{name:"Bob",age:45}
{name:"John",age:32}

And then when I try to do something like:


set thePerson to paragraph 1 of theRecords
display dialog name of thePerson

I get an error that it can’t get “name”. Does anyone have any suggestions for me? Basically, I wish AS had some ultra high level command like:


set thePerson to record 1 of (read (choose file))

It just occurred to me that what I’m really asking is if there is a way to convert a string to a record, and as far as I know that’s not possible. I.e.

set thePerson to "{name:\"Bob\",age:45}" as record


set theRecords to (read (choose file))
set aRecord to run script (paragraph 1 of theRecords)

age of aRecord
name of aRecord

-N

Well, that worked really well. Thanks. I’m just left wondering exactly what it is you did. What does “run script” do?