storing records in a text file

I have a php file writing out a list of records like so:
{name:“Joe”, client:“acme”}
{name:“Jane”, client:“acme”}

and then read them in with

set results to do shell script “/usr/local/php/bin/php -f /Users/sam/Desktop/records.php”
set resultList to results as list

it produces the list however the records are screwed because the quotes are escaped
{ {name:"Joe", client:"acme"}, {name:"Jane", client:"acme"} }

any idea what im doing wrong?

Is there a trick to storing records in a text file? I vaguely remember doing this a couple of years ago and I think there was something you need to do in order to store an applscript record in a text file.

This may or may not help, as it deals with lists: Delimited String to Array


You can write text, records, lists, etc. to text files. The following wirtes a list of records to text file using the ‘as’ parameter. It then reads ‘as list’.

set the_recs to {{name:“Joe”, client:“acme”}, {name:“Jane”, client:“acme”}}
set desk_path to (path to desktop) as string
set file_spec to (desk_path & “New file.txt”) as file specification
set ref_num to (open for access file_spec with write permission)
write the_recs to ref_num as list
close access ref_num
on error
close access ref_num
end try
set read_recs to (read file_spec as list)
set rec1 to item 1 of read_recs
{name of rec1, client of rec1}


thanks for that info.
I am talking about creating a record with php like
{{name:“Joe”, client:“acme”}, {name:“Jane”, client:“acme”}}
and then reading in that file.

But i imagine when applscript writes out a record there is some encoded stuff it writes along with it.
When i opened a file that i stored records in from applescript it contained a lot of text like this: list

Yes, I think such format isn’t public, but not so hard to reverse-engineer. Anyway, it’s not worth the effort. You can write your record as-is (as a simple string), then “read” it as follow:

set theRecord to (run script alias "path:to:record.txt")

You can find some tips about reverse-engineering records here: