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 properly access a vcard? #814

Open
plueschpruem opened this issue Jan 9, 2025 · 0 comments
Open

How to properly access a vcard? #814

plueschpruem opened this issue Jan 9, 2025 · 0 comments

Comments

@plueschpruem
Copy link

Thanks for this library!
But I am having hickups using it…

I am inputting a vcard in a string.
I parse it and see the resulting object, but I cannot figure out how to access all the data.

My code:

const ICAL = require("ical.js")

const vCardRaw = `BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//macOS 13.7//EN
N:Tester;Adam;;;
FN:Adam Tester
ORG:Party Inc.;
EMAIL;type=INTERNET;type=HOME;type=pref:[email protected]
TEL;type=CELL;type=VOICE;type=pref:+49 163 123456
TEL;type=IPHONE;type=CELL;type=VOICE:+49 163 654321
ADR;type=HOME;type=pref:;;Musterstraße 12;Beispielstadt;;15151;
item1.URL;type=pref:www.thehomepage.com
item1.X-ABLabel:_$!<HomePage>!$_
BDAY:1975-02-14
END:VCARD`

let myCard = ICAL.parse(vCardRaw);
console.log(myCard);

Result in console:

[
  'vcard',
  [
    [ 'version', {}, 'text', '3.0' ],
    [ 'prodid', {}, 'text', '-//Apple Inc.//macOS 13.7//EN' ],
    [ 'n', {}, 'text', [Array] ],
    [ 'fn', {}, 'text', 'Adam Tester' ],
    [ 'org', {}, 'text', [Array] ],
    [ 'email', [Object], 'text', '[email protected]' ],
    [ 'tel', [Object], 'phone-number', '+49 163 123456' ],
    [ 'tel', [Object], 'phone-number', '+49 163 654321' ],
    [ 'adr', [Object], 'text', [Array] ],
    [ 'url', [Object], 'uri', 'www.thehomepage.com' ],
    [ 'x-ablabel', [Object], 'unknown', '_$!<HomePage>!$_' ],
    [ 'bday', {}, 'date', '1975-02-14' ]
  ],
  []
]

How would I now either get it all as a JSON Object, or access the sub-property arrays?

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

No branches or pull requests

1 participant