Exemple #1
0
        public void CompactionWithEmbeddedContextUsingVocab()
        {
            var expandedContentDocument = JsonLdDocuments.SingleObject;
            var contextDocument         = JToken.Parse(@"{
                '@context': {
                    '@vocab': 'http://xmlns.com/foaf/0.1/',
                    'xsd': 'http://www.w3.org/2001/XMLSchema#',
                    'title': {
                        '@language': 'en'
                    },
                    'born': {
                        '@id': 'http://schema.org/birthDate',
                        '@type': 'xsd:date'
                    },
                    'gender': 'http://schema.org/gender',
                    'homepage': {
                        '@type': '@id'
                    },
                    'knows':
                    {
                        '@type': '@id'
                    }
                }
            }");
            var options         = new JsonLD.Core.JsonLdOptions();
            var contentDocument = JsonLD.Core.JsonLdProcessor.Compact(
                expandedContentDocument,
                contextDocument,
                options);

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #2
0
        public void ImposeStructureOnAGraphWithFraming()
        {
            var graphDocument   = JsonLdDocuments.Graph;
            var frameDocument   = JToken.Parse(@"{
                '@context': {
                    '@vocab': 'http://example.com/demo/vocab/',
                    'residentOf':
                    {
                        '@type': '@id'
                    },
                    'address':
                    {
                        '@type': '@id'
                    }
                },
                '@type':'Person',
                'residentOf': {
                    '@type':'Building',
                    'address': {
                        '@type':'Address'
                    }
                }
            }");
            var options         = new JsonLD.Core.JsonLdOptions();
            var contentDocument = JsonLD.Core.JsonLdProcessor.Frame(
                graphDocument,
                frameDocument,
                options);

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #3
0
        public void FlatteningOfNestedObjects()
        {
            var expandedContentDocument = JsonLdDocuments.NestedObjects;
            var contextDocument         = JToken.Parse(@"{
                '@context': {
                    '@vocab': 'http://xmlns.com/foaf/0.1/',
                    'xsd': 'http://www.w3.org/2001/XMLSchema#',
                    'born': {
                        '@id': 'http://schema.org/birthDate',
                        '@type': 'xsd:date'
                    },
                    'gender': 'http://schema.org/gender',
                    'homepage': {
                        '@type': '@id'
                    },
                    'knows':
                    {
                        '@type': '@id'
                    }
                }
            }");
            var options         = new JsonLD.Core.JsonLdOptions();
            var contentDocument = JsonLD.Core.JsonLdProcessor.Flatten(
                expandedContentDocument,
                contextDocument,
                options);

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #4
0
        public void CompactionOfGraphWithLocalContextUsingReverseProperty()
        {
            var expandedContentDocument = JsonLdDocuments.Graph;
            var contextDocument         = JToken.Parse(@"{
                '@context': {
                    '@vocab': 'http://example.com/demo/vocab/',
                    'residentOf':
                    {
                        '@type': '@id'
                    },
                    'homeOf': {
                        '@type': '@id',
                        '@reverse': 'residentOf'
                    },
                    'address':
                    {
                        '@type': '@id'
                    }
                }
            }");
            var options         = new JsonLD.Core.JsonLdOptions();
            var contentDocument = JsonLD.Core.JsonLdProcessor.Compact(
                expandedContentDocument,
                contextDocument,
                options);

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #5
0
        public void CompactionWithRemoteContext()
        {
            var     expandedContentDocument = JsonLdDocuments.SingleObject;
            var     contextDocument         = JToken.Parse(@"{
                '@context': [
                    {
                        'title': 'http://xmlns.com/foaf/0.1/title',
                    },
                    'https://json-ld.org/contexts/person.jsonld'
                ]
            }");
            var     options = new JsonLD.Core.JsonLdOptions();
            JObject contentDocument;

            try
            {
                contentDocument = JsonLD.Core.JsonLdProcessor.Compact(
                    expandedContentDocument,
                    contextDocument,
                    options);
            }
            catch (JsonLD.Core.JsonLdError exception)
                when(exception.Message == "loading remote context failed")
                {
                    Assert.Inconclusive("No access to remote context at 'https://json-ld.org/contexts/person.jsonld'");
                    return;
                }

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #6
0
        public void CompactionWithRemoteContext()
        {
            var expandedContentDocument = JsonLdDocuments.SingleObject;
            var contextDocument         = JToken.Parse(@"{
                '@context': [
                    {
                        'title': 'http://xmlns.com/foaf/0.1/title',
                    },
                    'https://json-ld.org/contexts/person.jsonld'
                ]
            }");
            var options         = new JsonLD.Core.JsonLdOptions();
            var contentDocument = JsonLD.Core.JsonLdProcessor.Compact(
                expandedContentDocument,
                contextDocument,
                options);

            Util.WriteLine(contentDocument.ToString());
        }
Exemple #7
0
 public virtual JsonLD.Core.JsonLdOptions Clone()
 {
     JsonLD.Core.JsonLdOptions rval = new JsonLD.Core.JsonLdOptions(GetBase());
     return(rval);
 }