Giter Club home page Giter Club logo

json-ld's People

Contributors

alariva avatar boly38 avatar cerw avatar homarx avatar isholgueras avatar jazz-man avatar jdgrieco avatar nokimaro avatar rdok-pigogo avatar torann avatar veganista avatar votemike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

json-ld's Issues

question about unexpected "</script>"

Hi
(you generator is very usefull, thanks)

I would like to know your opinion about the following use case:

As end user, I have html special char (like '<') into LD-JSON attributes

I write a little php script to represent the case:

<?php
require_once `vendor/autoload.php';

$context = \JsonLd\Context::create('news_article', [
    'headline' => 'Article headline',
    'description' => 'A terrible </script> here'
]);

echo $context;

echo "\n\nAn other way :\n\n";

$context = \JsonLd\Context::create('news_article', [
    'headline' => 'Article headline',
    'description' => htmlspecialchars('A terrible </script> here')
]);

echo $context;

Script output the following:

<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"NewsArticle","headline":"Article headline","description":"A terrible <\/script> here"}</script>

An other way :

<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"NewsArticle","headline":"Article headline","description":"A terrible &lt;\/script&gt; here"}</script>

You should notice that the first sample output an invalid HTML

I had created dedicated html page to show the escape issue:
https://gist.github.com/boly38/77164ae66055b596d75f62d789a4266a

I'm asking myself about where htmlspecialchars should be ?

  • on end-user side (like beside in the second sample)
  • or into the Torann library itself

what do you think?

As end-user, would be great that the library manages that point for me as, per specification, toString result is ready to embed html script.

thanks

Composer install not working

Hello Torann, I'm getting "Could not find package torann/json-ld at any version matching your PHP version 5.4.45.0" while trying to install your library. Even with --ignore-platform-reqs it's not working. Any ideas?

Support arrays: example 1 article embeds N comments

Hi

Using LD-JSON, it should be possible to define multiple times the same entity type on a given things.
For example, an Article could includes multiples "comments".
(need to confirm that point)

So out of error from me, mean that in this use case, 'comment' will be an array of objects ("Comment" type) and not a single entity. I think the library doens't allow us to do that?

I saw "breadcrumb" sample, but that seems to be a specific list example.

And as today, "field name" is used to work with ContextTypes attributes, so it will not be easy to implement?

Maybe should we use/implement @graph (src )?

The question is:

  • how to define an article with multiple comments using Torann/json-ld ?

Missing itemReviewed property for AggregateRating

AggregateRating should contain itemReviewed property.
https://schema.org/AggregateRating

Not sure, but it looks like property was removed at release >= 0.0.11

<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"AggregateRating","sameAs":"https:\/\/example.com/item","reviewCount":"129","ratingValue":"3.40","bestRating":5,"worstRating":1,"ratingCount":"129"}</script>

This is example context generated with current property-set for AggregateRating
You can check it at Google Schema Validator https://search.google.com/structured-data/testing-tool
Check result: 1 error - The review has no reviewed item specified.

2019-03-11 08_03_01-Structured Data Testing Tool - Opera

PHP v5.5.9 Support

Is PHP v5.5.9 actually not supported ?

Is there TravisCI builds history available for checking ?

Thanks in advance,

Product.php setIsSimilarToAttributes deletes "offers"

We have to modifiy this line:
$properties = array_filter($properties, 'strlen');

Because this line removes all arrays from product, which es added bei isSimilarTo property. For example: it removes "offers" , which is required for valid structured data.

Fix could be:
$properties= array_filter($properties, function($var) {
return !empty($var);
});

LocalBusiness Properties

Hi there and thanks for your nice work!
I'm missing a few important properties in LocalBusiness like:

  • priceRange
  • areaServed
  • hasMap
  • openingHours

and a few more.

Is there a way to extend this?

unique review in Article schema

Hi

I have a little problem when I have to add a list of reviews in the schema article it accepts just one review

'review' => Review::class

LodgingBusiness ContextType

I created a new ContextType file called LodgingBusiness. It looks like this:

<?php

namespace JsonLd\ContextTypes;

class LodgingBusiness extends LocalBusiness
{
    /**
     * Property structure
     *
     * @var array
     */
    protected $structure = [
        '@id' => null,
        'starRating' => null,
        'petsAllowed' => null,
    ];
}

I'm trying to use it like this:

$context = \JsonLd\Context::create('lodging_business', [
    'name' => $this->row->title,
]);

but i cant get any output. What am i doing wrong?

Proposal: drop support for PHP 5.6 and move to at least 7.2

Since PHP support for 5.6 has stopped long ago and even version 7.1 only has security support (until December 1st), I would like to propose to set the required PHP version to >=7.2. This would, allow for some clean up of code, enable more type hinting, etc.

Please let me know if other people would like move forward too or if there are any reasons why not to do this.

Nesting (e.g. Review inside Book, ratings inside reviews etc.)

Is passing one jsonld ContextType into another officially supported?
I assumed it would be, but none of the examples show it and I'm having loads of problems.

I've tried a couple of ways - e.g.

  • just nesting another call to \JsonLd\Context::create(Foo, $data) inside the main array
  • creating an entirely new instance with new \JsonLd\ContextTypes\Person()

Typically, the end output will either have an empty array where the nested context should be, or what looks like raw object data: i.e. only the @type defined and a "properties" array of everything, regardless of whether a value has been supplied - so mostly a long, empty list.

I've also come across situations where the second object works, but it fails on adding a third level (you may need to nest a Person (the reviewer) inside a Review inside a Book, for example).

Thanks in advance…

How to: Multiple products

Let me start, by thank you for the awesome simple code you've been maintaining @Torann.

More of a question, rather than an issue :

Our system needs to create a schema, connecting a product, with it's three most popular. Thus:

https://schema.org/Product -> https://schema.org/isSimilarTo -> Many https://schema.org/Product

For one product, no problem, we're awesome.

What about when we want to connect it to many other contexts products?

How might we go on to implement that feature? Is this the way to go? https://github.com/Torann/json-ld/pull/20/files

Thank you in advance

Is it possible to have multiple authors for article?

I'm trying to publish an article with multiple authors but all I get is the following without any author data.

"author": {
    "@type": "Author"
},

Is there a way to create an array like the following answer so it looks like the json below:
https://webmasters.stackexchange.com/a/90191

"author": [{
    "@type": "Person",
    "familyName": "van der Westhuizon",
    "givenName": "Jason",
    "name": "Jason van der Westhuizon"
},
{
    "@type": "Person",
    "familyName": "du Toit",
    "givenName": "Jene",
    "name": "Jene du Toit"
}]

Thank you!

Doesn't display 'headline' for the Blog Posting type?!

Ive noticed that if you chose Blog Post as the type - it doesnt display the 'headline' - even if its passed into the create method...i.e:

$JSONsructuredData = \JsonLd\Context::create('blog_posting', [
			'name'             => $post->title,
			'headline'         => $post->title,
			'datePublished'    => $post->publish_date->format('Y-m-d').'T'.$post->publish_date->format('H:m:s'),
			'dateModified'     => $post->publish_date->format('Y-m-d').'T'.$post->publish_date->format('H:m:s'),
			'image'            => [
				'type' => 'ImageObject',
				'url'  => env('APP_URL').$post->feature_image,
				'width'  => '850',
				'height' => '350'
			],
			'publisher'        => [
				'type' => 'Organization',
				'name' => 'SomeBlogSite',
				'logo' => [
					'type'   => 'ImageObject',
					'url'    => env('APP_URL').'img/logo/imge.png',
					'width'  => '600',
					'height' => '150'
				],
			],
			'mainEntityOfPage' => [
				'type' => 'WebPage',
				'id'   => env('APP_URL').'lobby/'.$post_slug,
			],
			'author'           => [
				'type' => 'Person',
				'name' => $post->user->name,
			],

		]);


It just ignores the ''headline' => $post->title,' - although I can see in the $structure of the CreativeWork Class it had 'headline' => null' ...but would appear it never actually sets it for display, even when passing in the value???

Cheers

Support for AggregateOffer is missing

AggregateOffer (https://schema.org/AggregateOffer) isn't supported and result in a normal Offer. Could this be added?

        return Context::create('product', [
            'name' => 'some name',
            'image' => [
                'https://site.com/image1.png',
                'https://site.com/image2.png'
            ],
            'description' => 'some description',
            'brand' => [
                '@type' => 'Brand',
                'name' => 'Awesome brand'
            ],
            'offers' => [
                '@type' => 'AggregateOffer',
                'offerCount' => 3,
                'lowPrice' => 100,
                'highPrice' => 200,
                'priceCurrency' => 'EUR'
            ]
        ]);

Expected:

{"@context":"http:\/\/schema.org","@type":"Product","name":"some name","description":"some description","brand":{"@type":"Brand","name":"Awesome brand"},"image":["https:\/\/site.com\/image1.png","https:\/\/site.com\/image2.png"],
"offers":{
    "@type":"AggregateOffer",
    "offerCount": "3",
    "lowPrice": "100",
    "highPrice": "200",
    "priceCurrency":"EUR"
}
}

Actual:

{"@context":"http:\/\/schema.org","@type":"Product","name":"some name","description":"some description","brand":{"@type":"Brand","name":"Awesome brand"},"image":["https:\/\/site.com\/image1.png","https:\/\/site.com\/image2.png"],
"offers":{
    "@type":"Offer",
    "priceCurrency":"EUR"
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.