mjhoffmeister / Hydra.NET

MIT License
4 stars 2 forks source link

How to deal with JSON-LD contexts #5

Open lambdakris opened 3 years ago

lambdakris commented 3 years ago

I wanted to start a conversation about how to deal with JSON-LD contexts in Hydra.NET. As far as I can tell, there is no built-in way to generate JSON-LD contexts for classes/resources. Is this accurate?

Assuming that it is, I have resorted to using JsonLd.Entities which works well, but it has some down sides. First, it requires separate steps to utilize in addition to the use of Hydra.NET which could conceivably be consolidated. Second, it depends on Newtonsoft.Json while Hydra.NET depends on System.Text.Json. Third, the project has a number of out of date dependencies and it has not seen much activity in the past 2 years. As a result, I was wondering whether it was advisable to either: 1 - Contribute to or fork JsonLd.Entities to upgrade dependencies and port to System.Text.Json 2 - Port relevant JsonLd.Entities functionality into Hydra.NET (but targeting System.Text.Json) 3 - Start a new project for dealing with JSON-LD Context generation and other JSON-LD related stuff for the purposes of Hydra.NET

mjhoffmeister commented 3 years ago

You can use the Context class, but it has limitations. It doesn't support context terms that map to maps, as illustrated in this JSON-LD spec example, and you have to manually build up a dictionary of terms to pass to the constructor if you're not using an IRI reference (that is elegant enough in my opinion, but that's just one opinion.)

I might prefer augmenting the Context class, but only slightly. Porting relevant JsonLd.Entities functionality into Hydra.NET is a close second. What do you think?

lambdakris commented 3 years ago

Yeah, I think it might be worthwhile to port over relevant functionality from JsonLD.Entities, specifically for building or generating contexts for POCOs. I was scanning the JsonLD.Entities code and it might not be too difficult to replicate with System.Text.Json and a bit of reflection (it might not be the fastest thing ever tho). I'll try to get an initial spike going this week!