Open RehanSaeed opened 4 years ago
Chad Boettcher commented on 2017-09-01 19:02:41
I'm having a problem initializing Values
objects. For example, if I'm creating an Organization
object, how to I initialize an Awards
object with 2 awards?
var organization = new Organization()
{
Address = new PostalAddress()
{
StreetAddress = this.CurrentWebsite.CustomerServiceAddress1,
AddressLocality = this.CurrentWebsite.CustomerServiceCity,
AddressRegion = this.CurrentWebsite.CustomerServiceState,
PostalCode = this.CurrentWebsite.CustomerServicePostalCode,
AddressCountry = "US"
},
Award = new Values()
{
// How do you do this for "Award 1" and "Award 2"
},
};
Chad Boettcher commented on 2017-09-06 22:39:55
Award = new List()
{
"Award 1",
"Award 2"
},
By the way, you sir, are a genius. This package saved me a TON of time! Thanks!
Muhammad Rehan Saeed commented on 2017-09-12 15:20:22
I'm having a problem initializing
Values
objects. For example, if I'm creating anOrganization
object, how to I initialize anAwards
object with 2 awards?var organization = new Organization() { Address = new PostalAddress() { StreetAddress = this.CurrentWebsite.CustomerServiceAddress1, AddressLocality = this.CurrentWebsite.CustomerServiceCity, AddressRegion = this.CurrentWebsite.CustomerServiceState, PostalCode = this.CurrentWebsite.CustomerServicePostalCode, AddressCountry = "US" }, Award = new Values() { // How do you do this for "Award 1" and "Award 2" }, };
This question is better suited to a GitHub issue. Like so:
var organization = new Organization()
{
Award = new List<string>()
{
"Award 1",
"Award 2"
},
};
You can use a List<T>
or T[]
array.
Steve commented on 2018-05-10 04:48:46
Great work!
I have a question tho, how can we set the dateCreated
to just the year of the book published?
Muhammad Rehan Saeed commented on 2018-05-10 10:43:33
Great work!
I have a question tho, how can we set the
dateCreated
to just the year of the book published?
I'm not sure what you mean but you can just set the property to a DateTimeOffset
value.
Steve commented on 2018-05-10 10:55:56
I'm not sure what you mean but you can just set the property to a DateTimeOffset value.
Normally, for our collection of books, we only have the publication year (we do not have the complete date)... How can we set the dateCreated
to just the year (eg 2007)? The DateTimeOffset
data type requires year, month and day.
Muhammad Rehan Saeed commented on 2018-05-10 11:01:28
Normally, for our collection of books, we only have the publication year (we do not have the complete date)... How can we set the
dateCreated
to just the year (eg 2007)? TheDateTimeOffset
data type requires year, month and day.
According to https://schema.org/dateCreated, the dateCreated
type only supports date
or dateTime
types. So setting the year alone is not possible.
Steve commented on 2018-05-10 11:19:25
I understand.
In https://schema.org/Date, it mentions that it should follow ISO8601 format. Which allows yyyy
date format.
ISO 8601 prescribes, as a minimum, a four-digit year [YYYY]... W3
Muhammad Rehan Saeed commented on 2018-05-10 11:27:15
I understand.
In https://schema.org/Date, it mentions that it should follow ISO8601 format. Which allows
yyyy
date format.ISO 8601 prescribes, as a minimum, a four-digit year [YYYY]... W3
Yes you are right...that's an interesting problem. The only way I can think to resolve it is for every date
property like dateCreated
, to add a format property like dateCreatedFormat
which would take a C# date format string. This could then be used in the serialization/deserialization.
Please do raise an issue in the Schema.NET GitHub site. We'll see if we can get that implemented or also feel free to submit a pull request.
Steve commented on 2018-05-10 11:53:09
Yes you are right...that's an interesting problem. The only way I can think to resolve it is for every
date
property likedateCreated
, to add a format property likedateCreatedFormat
which would take a C# date format string. This could then be used in the serialization/deserialization.Please do raise an issue in the Schema.NET GitHub page. We'll see if we can get that implemented or also feel free to submit a pull request.
Done. :)
Thanks for the quick response! Cheers!
Asad Butt commented on 2018-06-23 21:46:37
Thanks for this wonderful work. I'm having slight problem with adding logo
to my structure as it is not part of Article
object.
Any thoughts on that ?
Thanks
Muhammad Rehan Saeed commented on 2018-06-24 11:33:11
Thanks for this wonderful work. I'm having slight problem with adding
logo
to my structure as it is not part ofArticle
object. Any thoughts on that ? Thanks
Logo is not part of the article object on schema.org.
Vikas Singh commented on 2018-11-29 09:45:02
I'm having a problem initializing MedicalSpeciality
objects. For example, if I'm creating an Physician
object, how to I initialize a MedicalSpeciality
with multiple speciality?
var physician = new Physician()
{
Name = objModel.DoctorPersonalVM.DoctorName,
Url = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + objModel.DoctorPersonalVM.Slug),
Description = objModel.DoctorPersonalVM.AboutMe,
MedicalSpecialty = new MedicalSpecialty()
{
objModel.DoctorPersonalVM.Speciality
}
Award = new List<string>()
{
objModel.DoctorPersonalVM.AwardName,
},
};
Muhammad Rehan Saeed commented on 2018-12-01 11:00:50
I'm having a problem initializing
MedicalSpeciality
objects. For example, if I'm creating anPhysician
object, how to I initialize aMedicalSpeciality
with multiple speciality?var physician = new Physician() { Name = objModel.DoctorPersonalVM.DoctorName, Url = new Uri(Request.Url.GetLeftPart(UriPartial.Authority) + objModel.DoctorPersonalVM.Slug), Description = objModel.DoctorPersonalVM.AboutMe, MedicalSpecialty = new MedicalSpecialty() { objModel.DoctorPersonalVM.Speciality } Award = new List<string>() { objModel.DoctorPersonalVM.AwardName, }, };
Please raise a GitHub issue. This is not the right place to post issues.
Zander commented on 2019-04-01 13:36:41
Great work, Rehan!
I'm a bit confused - is there a way to deserialize JSON schema into Schema.NET C# Book
type (for example)?
Muhammad Rehan Saeed commented on 2019-04-01 14:04:19
Great work, Rehan!
I'm a bit confused - is there a way to deserialize JSON schema into Schema.NET C#
Book
type (for example)?
You can just use standard JSON serialization for that. See unit tests.
Asim Shahzad commented on 2019-07-17 13:19:58
Hi,
I have implement your solution. When I test it in google testing tool, tool does not show any thing to me. what will be the expected reason?
I'm using asp.net mvc.
{"@context":"http://schema.org","@type":"Organization","name":"Malik Express","sameAs":"https://www.facebook.com/malikexpress","url":"https://malikexpress.com","address":{"@type":"PostalAddress","addressCountry":"PK","addressLocality":"Islamabad","addressRegion":"ICT","postalCode":"44000","streetAddress":"Javed Plaza, A.K. Fazl-ul-Haq Rd, Block A G 6/3 Blue Area, Islamabad, Islamabad Capital Territory 44000"},"email":"info@malikexpress.com","logo":"https://malikexpress.com/Tempate/img/logo.png"}
Muhammad Rehan Saeed commented on 2019-07-17 16:23:35
hi,
I have implement your solution. When I test it in google testing tool, tool does not show any thing to me. what will be the expected reason?
I'm using asp.net mvc.
{"@context":"http://schema.org","@type":"Organization","name":"Malik Express","sameAs":"https://www.facebook.com/malikexpress","url":"https://malikexpress.com","address":{"@type":"PostalAddress","addressCountry":"PK","addressLocality":"Islamabad","addressRegion":"ICT","postalCode":"44000","streetAddress":"Javed Plaza, A.K. Fazl-ul-Haq Rd, Block A G 6/3 Blue Area, Islamabad, Islamabad Capital Territory 44000"},"email":"info@malikexpress.com","logo":"https://malikexpress.com/Tempate/img/logo.png"}
Hard to say with this much information.
larrybud commented on 2020-01-14 01:10:19
It should be noted that to output this in razor syntax, you must use
@Html.Raw()
So the example above which says:
var jsonLd = website.ToString();
The output should be
@Html.Raw(website)
If you just do
@jsonLd
You'll get html encoded strings, which is no good.
Hi Rehan,
I have a doubt regarding SiteNavigationElement. Can you please tell me where can we assign the list of SiteNavigationElement in Website object. Unable to find. Thanks.
https://rehansaeed.com/structured-data-using-schema-net/