- From: vikash agrawal <vikashagrawal1990@gmail.com>
- Date: Tue, 20 Aug 2013 11:43:09 +0530
- To: Linked JSON <public-linked-json@w3.org>
- Message-ID: <CAKpG3NjMxm47erPMqk2jN-yEMCz=0p-fiNLdtJ7qnHTX-16fOA@mail.gmail.com>
Hello Everyone, This week I was working upon LinkedIn tool. I have added a major fields that I feel is great. [So far these are already pushed on github] [1] On the PR, Manu had commented "The ideal way to do the translation that you're doing isn't to hard code it like you have. It's to provide a JSON-LD context for the JSON you get back from LinkedIn, and then use the JSON-LD library's .compact() method to convert the LinkedIn data to schema.orgdata." So, over this I had a discussion and he told me quiet simple solutions to handle this:-var linkedInData = fetchLinkedInData(); linkedInData["@context"] = myLinkedInJsonLdContext; var schemaOrgLinkedInData = jsonld.compact(linkedInData, mySchemaOrgContext); So, essentially now, my task for this week would be primarily writing contexts on LinkedIN JSON values, Also I have to understand the .compact() method. But on looking on the structure of JSON. It seems pretty weird for me. I would like to share a few instance here :- 1) Date of Birth - LinkedIn docs says "May return only month and day, but not year, or all three, depending on information provided.", And a xsd:date is valid with yyyy-mm-dd so, how to do things for this bit. What I think is ------ for (i in result.values[0].dateOfBirth) { if (result.values[0].dateOfBirth.hasOwnProperty(i)) { count++; } } if(count == 3) { user["birthDate"] = result.values[0].dateOfBirth.year+'-'+result.values[0].dateOfBirth.month+'-'+result.values[0].dateOfBirth.day; } count = 0; ----- which means if the date has yyyy with mm-dd then only display that and then in context I will have something like : {... "birthDate" : " http://schema.org/birthDate", ...}. Also is the above statement for user["birthdate"] is wrong? 2) Say we have "educations", which is essentially an object and whose first field _total gives the total number of objects under it. Along with the the each object under values may or may not have "fieldOfStudy" depending upon school/college. So how should this be handled in contexts? 3) Similarly it goes for few other objects. ------ So, essentially once I write a valid context soon, I would test it and push it soon :-) Regards ~Vikash [1] - https://github.com/json-ld/json-ld.org/pull/294
Received on Tuesday, 20 August 2013 06:14:16 UTC