diff --git a/src/json-ld.net/Core/JsonLdApi.cs b/src/json-ld.net/Core/JsonLdApi.cs
index 186d913..6672070 100644
--- a/src/json-ld.net/Core/JsonLdApi.cs
+++ b/src/json-ld.net/Core/JsonLdApi.cs
@@ -430,8 +430,7 @@ public virtual JToken Compact(Context activeCtx, string activeProperty, JToken e
///
/// JsonLdError
///
- public virtual JToken Expand(Context activeCtx, string activeProperty, JToken element
- )
+ public virtual JToken Expand(Context activeCtx, string activeProperty, JToken element)
{
// 1)
if (element.IsNull())
@@ -1405,7 +1404,7 @@ public virtual JArray Frame(JToken input, JArray frame)
{
state.omitDefault = this.opts.GetOmitDefault().Value;
}
- // use tree map so keys are sotred by default
+ // use tree map so keys are sorted by default
// XXX BUG BUG BUG XXX (sblom) Figure out where this needs to be sorted and use extension methods to return sorted enumerators or something!
JObject nodes = new JObject();
GenerateNodeMap(input, nodes);
@@ -2116,7 +2115,12 @@ public virtual JArray FromRDF(RDFDataset dataset)
JArray result = new JArray();
// 6)
JArray ids = new JArray(defaultGraph.GetKeys());
- ids.SortInPlace();
+
+ if (opts.GetSortGraphsFromRdf())
+ {
+ ids.SortInPlace();
+ }
+
foreach (string subject_1 in ids)
{
JsonLdApi.NodeMapNode node = (NodeMapNode)defaultGraph[subject_1];
@@ -2127,7 +2131,12 @@ public virtual JArray FromRDF(RDFDataset dataset)
node["@graph"] = new JArray();
// 6.1.2)
JArray keys = new JArray(graphMap[subject_1].GetKeys());
- keys.SortInPlace();
+
+ if (opts.GetSortGraphNodesFromRdf())
+ {
+ keys.SortInPlace();
+ }
+
foreach (string s in keys)
{
JsonLdApi.NodeMapNode n = (NodeMapNode)graphMap[subject_1][s];
diff --git a/src/json-ld.net/Core/JsonLdOptions.cs b/src/json-ld.net/Core/JsonLdOptions.cs
index 2478481..ebd2cc2 100644
--- a/src/json-ld.net/Core/JsonLdOptions.cs
+++ b/src/json-ld.net/Core/JsonLdOptions.cs
@@ -1,4 +1,3 @@
-using JsonLD.Core;
using Newtonsoft.Json.Linq;
namespace JsonLD.Core
@@ -43,6 +42,9 @@ public virtual JsonLD.Core.JsonLdOptions Clone()
private bool produceGeneralizedRdf = false;
+ private bool sortGraphsFromRdf = true;
+
+ private bool sortGraphNodesFromRdf = true;
// base options
// frame options
// rdf conversion options
@@ -147,6 +149,25 @@ public virtual void SetProduceGeneralizedRdf(bool produceGeneralizedRdf)
this.produceGeneralizedRdf = produceGeneralizedRdf;
}
+ public virtual bool GetSortGraphsFromRdf()
+ {
+ return sortGraphsFromRdf;
+ }
+
+ public virtual void SetSortGraphsFromRdf(bool sortGraphs)
+ {
+ this.sortGraphsFromRdf = sortGraphs;
+ }
+
+ public virtual bool GetSortGraphNodesFromRdf()
+ {
+ return sortGraphNodesFromRdf;
+ }
+
+ public virtual void SetSortGraphNodesFromRdf(bool sortGraphNodes)
+ {
+ this.sortGraphNodesFromRdf = sortGraphNodes;
+ }
public string format = null;
public bool useNamespaces = false;
diff --git a/src/json-ld.net/Core/JsonLdProcessor.cs b/src/json-ld.net/Core/JsonLdProcessor.cs
index f383f2c..b77acbb 100644
--- a/src/json-ld.net/Core/JsonLdProcessor.cs
+++ b/src/json-ld.net/Core/JsonLdProcessor.cs
@@ -13,8 +13,7 @@ namespace JsonLD.Core
public class JsonLdProcessor
{
///
- public static JObject Compact(JToken input, JToken context, JsonLdOptions
- opts)
+ public static JObject Compact(JToken input, JToken context, JsonLdOptions opts)
{
// 1)
// TODO: look into java futures/promises
diff --git a/src/json-ld.net/Core/NormalizeUtils.cs b/src/json-ld.net/Core/NormalizeUtils.cs
index 91aa552..bf746ed 100644
--- a/src/json-ld.net/Core/NormalizeUtils.cs
+++ b/src/json-ld.net/Core/NormalizeUtils.cs
@@ -108,6 +108,7 @@ public virtual object HashBlankNodes(IEnumerable unnamed_)
normalized.Add(RDFDatasetUtils.ToNQuad(quad, quad.ContainsKey("name"
) && !(quad["name"] == null) ? (string)((IDictionary)((IDictionary)quad)["name"])["value"] : null));
}
+
// sort normalized output
normalized.SortInPlace();
// handle output format
diff --git a/src/json-ld.net/json-ld.net.csproj b/src/json-ld.net/json-ld.net.csproj
index 1d4f881..3bd4f7c 100644
--- a/src/json-ld.net/json-ld.net.csproj
+++ b/src/json-ld.net/json-ld.net.csproj
@@ -3,7 +3,7 @@
JSON-LD processor for .NET
Implements the W3C JSON-LD 1.0 standard.
- 1.0.6
+ 1.0.7
NuGet;linked-data-dotnet
netstandard1.3;netstandard2.0;netcoreapp2.1
json-ld.net
diff --git a/test/json-ld.net.tests/ConformanceTests.cs b/test/json-ld.net.tests/ConformanceTests.cs
index 02eaa82..09bcaf8 100644
--- a/test/json-ld.net.tests/ConformanceTests.cs
+++ b/test/json-ld.net.tests/ConformanceTests.cs
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using Newtonsoft.Json.Linq;
using Xunit;
-using Xunit.Extensions;
using System.IO;
-using Newtonsoft.Json;
using JsonLD.Core;
using JsonLD.Util;
@@ -16,7 +13,7 @@ namespace JsonLD.Test
public class ConformanceTests
{
[Theory, ClassData(typeof(ConformanceCases))]
- public void ConformanceTestPasses(string id, string testname, ConformanceCase conformanceCase)
+ public void ConformanceTestPasses(string id, ConformanceCase conformanceCase)
{
JToken result = conformanceCase.run();
if (conformanceCase.error != null)
@@ -77,20 +74,21 @@ public ConformanceCases()
public IEnumerator