5

I've added a little more of my work to show how I'm thinking

I hope this question isn't too broad. I'm thinking through a number of things and thought I'd try to put a "basic" question down here.

I have some data for a game I play with some friends online. I have a very simple php page which spits out some data from a database that looks like this:

[
{
    "Name": "David Alger",
    "Id": "1",
    "Username": "Dave",
    "Colour": "green"
},
{
    "Name": "John Smith",
    "Id": "2",
    "Username": "JohnS",
    "Colour": "blue"
    }
]

It's simply the player info, with a local ID, a username and a colour used to show the player in the game (it's actually just used as a colour in HTML).

Since I've been looking at JSON-LD I began to think about making this JSON data into JSON-LD.

My question then becomes:

1) Is it worth making this data (or data like it) into JSON-LD just "in case we want to open it up one day"? Or would that be, typically, a waste of energy?

2) How would I make this JSON-LD? What makes sense to "link" and how would that look?

I've been playing a little with ideas like allowing individual 'players' to be returned rather than all coming at once, then each getting a URI for an ID. (Can this be a simple url like example.com/player?id=1 or does it have to be more as I have shown?) I've also looked at: - using the idea of context for a type like person. - using "sameAs", but it's unclear if that will automatically 'work' in this format? - trying to specify what items like "colour" are, by giving it a context.

{  
  "@context": {        
    "name": "http://schema.org/name",
    "Colour": "http://dbpedia.org/ontology/Colour"
  },
  "@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"    
}

It feels rather like I'm blundering around in the dark. So any help is appreciated.

3
  • What does "in case we want to open it up one day have to do with JSON-LD? It's for linking data across websites.
    – user4293
    Commented Jul 15, 2015 at 8:56
  • Well, I'm looking at the idea that we have data that could be linked/linkable but is not currently open/accessible. Is it worth adding the LD context to our data as a sort of default setting, or would that be illogical until there is a need/desire to link it or be linked to?
    – Dave Alger
    Commented Jul 15, 2015 at 17:35
  • 1
    Adding a JSON-LD context certainly would clarify the semantics of your JSON data structures. I find it far more useful than a plain JSON document, especially if the context is well documented. JSON data is remarkably cryptic, and you may find that it benefits your own organization (as well as any 3rd party consumers) to document your data structures.
    – metamattj
    Commented Jul 24, 2015 at 19:12

1 Answer 1

1

Something that would influence how you structure this JSON is how you are using it. Do you have a client that consumes this JSON?

The first and easiest thing you might do would be to define @id as a URI (http/s link). That might give you the chance to use the URI in your own code to refer to the user (which might otherwise be a URL that must be constructed by the client). You could also have profile pages live at that URL when the request is for HTML, and return the JSON data when the request is for JSON.

1
  • I think this is a good start point. Thanks. I added a simple URI for @id. I'm a little uncertain whether one can use simple parameters (e.g. player.php?id=1) I'm given to understand that's not recommend, but I wonder it's permissible all the same.
    – Dave Alger
    Commented Oct 14, 2015 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.