Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert standard vCard into first-class JSON? #77

Open
ppKrauss opened this issue Jan 8, 2017 · 5 comments
Open

How to convert standard vCard into first-class JSON? #77

ppKrauss opened this issue Jan 8, 2017 · 5 comments

Comments

@ppKrauss
Copy link

ppKrauss commented Jan 8, 2017

There are an ez-vcard option or parameter for it?

I need a stable and secure convertion, that produce the final output as "first class" JSON objects. Example:

  • jCard format: [["version", {}, "text", "4.0"],["fn", {}, "text", "Forrest Gump"]]

  • First-class JSON format: {"version":"4.0","fn":"Forrest Gump"}.

@mangstadt
Copy link
Owner

Sorry, ez-vcard does not produce the kind of JSON output you are looking for.

@ppKrauss
Copy link
Author

ppKrauss commented Jan 9, 2017

Hi @mangstadt , thanks! Well, can I help to draft and perhaps develop something for ez-vcard?

I understand that the reversibility ("round-tripping" as RFC 7095) is a key feature of jCard, and it is only possible with expresstions as ["lang", { "pref": "1" }, "language-tag", "fr"], mapping spetial properties, parameters or values. So, jCard can be used as intermediary format (the input) for any other non-reversible format. It is like to write a "vCard report".

The usual goal of non-reversible formats are to express in simplifyed (but also "standard") way the vCard information, for simpler applications... Perhaps the main demand is the construction of Semantic Web expressions, where SchemaOrg is today a de facto standard. See Person, Organization and ContactPoint.


The key files seems JCardRawWriter.java and perhaps JsonValue.java... What do you suggest as a starting point?

@ppKrauss
Copy link
Author

ppKrauss commented Jan 9, 2017

Before to move on, in this line of "simple and first-class JSON" (my preference), perhaps you want to check other complex reversible format, the JSON-LD as #78. If we confortable with "simple first", let me explain better.

Maping vCard to SchemaOrg, with equivalences at xCard:

vCard Class Property xCard
FN Person name fn/text
N[1] Person familyName surname
N[2] Person givenName given
N[3] Person additionalName additional
N[4] Person honorificPrefix prefix
N[5] Person honorificSuffix suffix
ORG Organization name org/text
EMAIL Person email email/text
TEL Person telephone tel/uri
BDAY Person birthDate ...
LABEL;HOME Person address adr/parameters/label
LABEL;WORK Organization address ...
ADR[1] PostalAddress postOfficeBoxNumber adr/pobox
ADR[2] PostalAddress ... adr/ext
ADR[3] PostalAddress streetAddress adr/street
... ... ... ...

So there are two natural alternatives to reuse labels: from xCard or from SchemaOrg... But only SchemaOrg is a de facto standard, and express semantic hierarchy, so I prefer SchemaOrg.

Example (from this Wikipedia example):

...
"Person":{
   "name":"Forrest Gump",
   "familyName":"Forrest",
   "givenName":"Gump",
   "honorificPrefix":"Mr.",
   "address":"42 Plantation St.\nBaytown, LA 30314\nUnited States of America",
   "PostalAddress":{
      "streetAddress":"42 Plantation St.",
      "city":"Baytown",
      "postalCode":"30314",
      "addressCountry":"United States of America"
    },
   "telephone":"+1-404-555-1212"
},
"Organization":{
   "name":"Bubba Gump Shrimp Co.",
   "telephone":"+1-111-555-1212",
   "address":"100 Waters Edge\nBaytown, LA 30314\nUnited States of America",
   "PostalAddress":{}
},
...

@mangstadt
Copy link
Owner

I would treat it as an entirely new data format, and start by creating a new "writer" class.

You could use one of the existing writer classes as a starting point. Because it's based on JSON, you could use the JCardWriter class.

@NightMachinery
Copy link

@ppKrauss I have written a JSON outputter using ez-vcard, which might satisfy your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants