Skip to content

JsonLd to NQuads changes DataTime values to non-standard values #10

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

Closed
ludgerey opened this issue Jun 22, 2015 · 4 comments
Closed

JsonLd to NQuads changes DataTime values to non-standard values #10

ludgerey opened this issue Jun 22, 2015 · 4 comments

Comments

@ludgerey
Copy link

var jsonLdString = "..." // contains "2015-06-22T17:37:04.1656245+02:00"
var jsonLd = JSONUtils.FromString(jsonLdString); 
var nquads = (string) JsonLdProcessor.ToRDF(jsonLd, new NQuadTripleCallback()); // contains "06/22/2015 17:37:04"

I am using your library to convert json-ld to nquads but it changes xsd-datetime-format to something else. It should prevent the previous format or it should use a format that is compatible with the provided type ("http://www.w3.org/2001/XMLSchema#dateTime").

Extract from JSON-LD:

[...]
          "ns:date": {
            "@type": "xsd:dateTime",
            "@value": "2015-06-22T17:37:04.1656245+02:00"
          },
[...]

Extract from NQuad:

[...]
    <http://ns#EmailMessage-8259dce5-eb15-4dc8-bace-40c138fc594f> <http://ns#date> "06/22/2015 17:37:04"^^<http://www.w3.org/2001/XMLSchema#dateTime> <http://ns#EmailMessage-8259dce5-eb15-4dc8-bace-40c138fc594f> .
[...]
@ludgerey
Copy link
Author

My hack for this:

var jsonLd = JSONUtils.FromString(jsonLdString);
var nquads = (string) JsonLdProcessor.ToRDF(jsonLd, new NQuadTripleCallback());

// restore DateTimes
var regex = new Regex(@"""([^""]+)""\^\^<http://www.w3.org/2001/XMLSchema#dateTime>");
var matches = regex.Matches(nquads);
foreach (Match match in matches)
{
      var dateStr = match.Groups[1].Value;
      var date = DateTime.Parse(dateStr, new CultureInfo("en-US"));
      nquads = nquads.Replace(dateStr, XmlConvert.ToString(date, XmlDateTimeSerializationMode.Local));
}

@asbjornu
Copy link
Member

This might be fixed in d953401 as a part of #14.

@tpluscode
Copy link
Collaborator

Indeed, this looks like the same issue

@emgarten
Copy link
Contributor

Closing this as fixed in 1.0.5
5bdd4e8

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

4 participants