コード例 #1
0
        /// <summary>
        /// Returns the <see cref="RDFDataset" /> from the REST API response.
        /// </summary>
        /// <param name="response">The REST API response.</param>
        /// <returns>The <see cref="RDFDataset"/> from the REST API response.</returns>
        protected override RDFDataset LoadEntity(IRestResponse response)
        {
            var token = JSONUtils.FromString(response.Content);

            model        = (RDFDataset)JsonLdProcessor.ToRDF(token, options);
            defaultQuads = model.GetQuads("@default");

            return(model);
        }
コード例 #2
0
        public NormalizedRdf NormalizeRdf(HashSet <Triple> triples)
        {
            var    model         = _rdf4jMapper.TriplesToGraph(triples);
            string modelAsJsonLd = _rdf4jMapper.GraphToSerialization(model, new VDS.RDF.Writing.JsonLdWriter());

            //fix for JsonLdWriter bug
            modelAsJsonLd = modelAsJsonLd.Replace("@language\": \"http:", "@type\": \"http:");
            try
            {
                var jsonObject           = JSONUtils.FromString(modelAsJsonLd);
                var normalizedJsonObject = JsonLdProcessor.Normalize(jsonObject, PrepareJsonLdOptions());

                return(new NormalizedRdf(new RdfDataset(triples), normalizedJsonObject.ToString(), RdfFormat.JSON_LD));
            }
            catch (IOException ex)
            {
                throw new NormalizingRdfException("Exception was thrown while normalizing JSON object.", ex);
            }
            catch (JsonLdError ex)
            {
                throw new NormalizingRdfException("Exception was thrown while normalizing JSON object.", ex);
            }
        }