-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sample1_Compact.cs
40 lines (34 loc) · 1.07 KB
/
Sample1_Compact.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
using Res = JsonLD.Demo.Resources.Resources;
using System;
using JsonLD.Core;
using Newtonsoft.Json.Linq;
namespace JsonLD.Demo
{
public class Sample1_Compact
{
private static readonly string _contextJson = Res.ReadString("context.json");
private static readonly string _docJson = Res.ReadString("doc.json");
public static JObject Run()
{
var doc = JObject.Parse(_docJson);
var context = JObject.Parse(_contextJson);
var opts = new JsonLdOptions();
var compacted = JsonLdProcessor.Compact(doc, context, opts);
Console.WriteLine(compacted);
/*
Output:
{
"@id": "ld-experts",
"member": {
"image": "http://manu.sporny.org/images/manu.png",
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/",
},
"name": "LD Experts",
"@context": . . .
}
*/
return compacted;
}
}
}