Re: Use XML to create extensible data structures in text fields?
Re: Use XML to create extensible data structures in text fields?
- Subject: Re: Use XML to create extensible data structures in text fields?
- From: Shane Stanley <email@hidden>
- Date: Sat, 25 Nov 2017 11:05:03 +1100
On 25 Nov 2017, at 10:31 am, Michael Grant <email@hidden> wrote:
>
> All else being equal, better human readability is certainly a plus.
OK. Here's a sample of JSON from the JSON Wikipedia page:
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021"
},
"phoneNumber": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
],
"gender": {
"type": "male"
}
}
Her's the same thing from the same source, using XML with attributes:
<person firstName="John" lastName="Smith" age="25">
<address streetAddress="21 2nd Street" city="New York" state="NY"
postalCode="10021" />
<phoneNumber type="home" number="212 555-1234"/>
<phoneNumber type="fax" number="646 555-4567"/>
<gender type="male"/>
</person>
I don't know whether one is more readable than the other, although I reckon the
latter is less likely to be mangled by direct editing.
Now you may not want to use attributes like that -- it's certainly going to
involve more code than using simple property lists. But then property lists
remove the chore of converting things like dates to a text or numerical format
and vice-versa, which would be required with JSON (and XML using attributes
like the above).
I'm not saying XML is necessarily a better choice -- just that you need to
consider the pros and cons for your particular requirements, which are quite
different from those of people building http-based client-server apps.
--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden