RehanSaeed / Schema.NET

Schema.org objects turned into strongly typed C# POCO classes for use in .NET. All classes can be serialized into JSON/JSON-LD and XML, typically used to represent structured data in the head section of html page.
MIT License
641 stars 80 forks source link

graph support enhancement #132

Open jtkent opened 4 years ago

jtkent commented 4 years ago

Do you have any plans to implement the @graph syntax to allow for mulitple JSON-types to be written at once.

Example: https://stackoverflow.com/questions/30505796/json-ld-schema-org-multiple-video-image-page/

This would allow for writing of only one script element rather than mulitple.

RehanSaeed commented 4 years ago

Interesting. I was not aware of the @graph property. I think it would be fairly straightforward to add a new property to the base JsonLdObject class:

[DataMember(Name = "@type", Order = 1)]
public virtual string Type { get; }

[DataMember(Name = "@graph", Order = 2)]
public virtual Thing Graph { get; }

The only reall work will be to add some smarts to the JSON serializer to switch between using the type property or the graph property.

vmateianu commented 4 years ago

This library is awesome, however missing support for entity graphs is a huge drawback.

https://yoast.com/regarding-googles-related-entities-patent/

RehanSaeed commented 4 years ago

Would be willing to take a PR if you're really interested.

maraerben commented 1 year ago

Any news here? Is it possible to merge enclosed MR #182 ? It would be very useful for us.

Turnerj commented 1 year ago

Hey @maraerben - Currently #182 is only the most surface level changes needed, I haven't yet got around to any further development for it. My last comment on the PR covers generally what I think we'd need to do for graph support but it has been a while since I've taken a deep dive at it.

I don't know when I'd be getting back to it myself so I'd definitely welcome any PRs to add graph support in the mean time.

wstaelens commented 1 year ago

what is the status of @graph ?