Toby A Inkster schrieb:
Gordon wrote:
Unfortunately, all Microformat parsers yield different results when it
comes to representing hCards in Json. None follows the jCard standard
suggested at http://microjson.org/wiki/JCard.
The suggestion at that page defined new terms for various VCARD
properties. For example, "postal-code" becomes "postalCode". (Yes, I do
realise that hyphenated names are more difficult to use as JSON keys in
Javascript.)
There is no pattern to how these new terms are defined. e.g. the example
above drops the hyphen and adopts camelCase, but "given-name" apparently
becomes "given", and "adr" becomes "address". With these inconsistencies
in naming, the only way an author could implement jCard would be if there
was a full table mapping between hCard and jCard terms. There is no such
table on that page -- authors need to make guesses.
Whatsmore, in the example given, "tel" takes a single string as a value,
whereas surely it should be an array? People can have multiple phone
numbers. Ditto the single string for "email" and the single object for
"address".
If these issues could be addressed, I'd be happy to work on a jCard output
module for Cognition.
Good call. I'd say the most obvious solution would be to make all
properties that can have multiple occurences into plurals, so "nickname"
becomes "nicknames", "email" becomes "emails" and so on. Properties that
appear multiple times but contain a simple datatype should be Arrays of
that datatype, so nicknames is an Array of Strings, while eMails is an
Array of Objects, because an email has a type and a value. I'd suggest
using an Array to hold this Object even if there is just one Object inside.
For singular properties I suggest singular naming, so fn stays fn.
Singular properties with a complex datatype, like n hold one
corresponding Object. I suggest we camelize any hypenated properties,
though I wouldn't mind underscoring them either.
I have prepared a quick diagram that might help to headstart this:
http://lib.omnia-computing.de/images/JCard.png
_______________________________________________
microformats-discuss mailing list
microformats-discuss@microformats.org
http://microformats.org/mailman/listinfo/microformats-discuss