0

As a simple exercise I wanted to take some test-data from a little app I had which produced a user record in JSON and turn it into JSON-LD, testing on JSON-LD.org's playground gives some help, but I don't know if I'm doing it right.

The original is:

[
    {
        "Id": 1
        "Username": "Dave",
        "Colour":"green“
    }
]

So I have a person, who has a username, an ID and an associated colour.

What I've got so far is:

{  
  "@context": {    
    "name": "http://schema.org/name",
    "Colour": {
      "@id": "http://dbpedia.org/ontology/Colour",
      "@type": "http://schema.org/Text",
      "@language": "en"
    }
  },
  "@type": "http://schema.org/Person",     
  "@Id": "http://example.com/player/1",
  "sameAs" : "https://www.facebook.com/DaveAlger",
  "Id": 1,
  "name": "David Alger",
  "Username": "Dave",  
  "Colour": "green" 
}

So I'm declaring it's a @type of person, and given a URI @id.

I'm also using the "sameAs" idea, which I saw on a blog-post once, but am unclear if it is just supported right off.

Then I've tried to create a @context. Here that I've added a name and given that a reference. I've tried to create something for "colour" too. I'm not sure if pointing to a DBpedia reference about "colour" and specifying a @type and @language is good, or not.

I suppose the final thing is "username", but that feels so deeply internal to a site that it doesn't make sense to "Link" it at all.

I'm aware this data is perhaps not even worth linking, this is very much a learning exercise for me.

Dave Alger
  • 339
  • 7
  • 23

1 Answers1

1

I don’t think that http://dbpedia.org/ontology/Colour should be used like that. It’s a class, not a property. The property that has http://dbpedia.org/ontology/Colour as range is http://dbpedia.org/ontology/colour. (That said, I’m not sure if your really intend that the person should have a colour, instead of something related to this person.)

If you want to provide the language of the colour strings, you should not specify the datatype, @language is sufficient (if a value is typed, it can’t have a language anymore; by using @language, it’s implied that the value is a string).

You are using @Id for specifying the node’s URI, but it must be @id.

The properties sameAs, Id and Username are not defined in your @context.

  • If you intend to use Schema.org’s sameAs property, you could define it similar to what you did with name, but you should specify that the value is a URI:

    "sameAs": {
      "@id": "http://schema.org/sameAs",
      "@type": "@id"
    },
    
  • For Username, you could use FOAF’s nick property, or maybe Schema.org’s alternateName property.

  • No idea which property you could use for Id (depends on your case if this is useful for others at all, or if this is only relevant for your internal system).

unor
  • 92,415
  • 26
  • 211
  • 360
  • Some really good and helpful points here I think. Interesting to see the difference between a class and property, that helps. It also brings something else into focus: this object I'm specifying is a "player record", and the player has a "colour" in a game and that player is also a person (which can be linked to the person on Facebook), but is it wrong then to declare the object type as person? Should there be a more subtle link? Of the sort that this player, who has a username is also the person with the name and related same as? – Dave Alger Oct 19 '15 at 06:33
  • @DaveAlger: That’s a good question, but I guess it’s too complex for answering it in a comment (and it’s more healthy for the site to have this in an actual answer post which can be down-voted/edited), and I’m sure there are different opinions about it. – unor Oct 19 '15 at 17:53