-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample3_Flatten.cs
47 lines (41 loc) · 1.29 KB
/
Sample3_Flatten.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Res = JsonLD.Demo.Resources.Resources;
using System;
using JsonLD.Core;
using Newtonsoft.Json.Linq;
namespace JsonLD.Demo
{
public class Sample3_Flatten
{
private static readonly string _contextJson = Res.ReadString("context.json");
private static readonly string _docJson = Res.ReadString("doc.json");
public static void Run()
{
var doc = JObject.Parse(_docJson);
var context = JObject.Parse(_contextJson);
var opts = new JsonLdOptions();
var flattened = JsonLdProcessor.Flatten(doc, context, opts);
Console.WriteLine(flattened);
/*
Output:
{
"@context": . . .,
"@graph": [
{
"@id": "_:b0",
"image": "http://manu.sporny.org/images/manu.png",
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
},
{
"@id": "ld-experts",
"member": {
"@id": "_:b0"
},
"name": "LD Experts"
}
]
}
*/
}
}
}