Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a pre-processing step option for the API #149

Closed
msporny opened this issue Jul 30, 2012 · 9 comments
Closed

Create a pre-processing step option for the API #149

msporny opened this issue Jul 30, 2012 · 9 comments

Comments

@msporny
Copy link
Member

msporny commented Jul 30, 2012

Should we add an optional parameter for all API calls that could pre-process all key-values found in JSON-LD API input in an arbitrary manner? For example:

function myFunc(key, value) {
  if(key === 'position') {
    return {'latitude': value[0], 'longitude': value[1]};
  }
};

jsonld.expand(data, {'preprocess': myFunc}, callback);

This approach would address issue #146, and may be useful for other sorts of migration that would otherwise complicate JSON-LD.

//cc @retobg

@gkellogg
Copy link
Member

On the RDF call, Sandro strongly objected to this notion. We need to tread carefully. Personally, I think it's a matter or clarification, but I think it should be folded into expansion.

@lanthaler
Copy link
Member

The question is whether this really needs to be attached to the API itself!? In my opinion it is trivial to write such a pre-processing step without having to resort to the official API or am I missing something?

@msporny
Copy link
Member Author

msporny commented Jul 31, 2012

@gkellogg I do think it's a matter of clarification as I don't see how a pre-processing step is that dangerous for data we don't intend to support. That is, people are going to do it anyway, and we need to formalize the best way to do it.

@lanthaler It's true that it doesn't technically need to be attached to the API itself. What we found, though, with RDFa Lite was that if you spell out certain features in the spec... even if they're fairly obvious to the folks that know the spec, people have an easier time accepting the "best practice" and using it. Otherwise, there can be confusion around what a best practice entails... and if the spec is silent on it, it can lead to people asserting that the intent was never to pre-process data that didn't fit the JSON-LD model. So, it always helps to be a bit more explicit in the specs with practices that we expect to see in the wild.

@lanthaler
Copy link
Member

... I see it from the opposite side. I find it rather dangerous to declare constructs that would otherwise be un-conformant JSON-LD to best practices.

@retog
Copy link

retog commented Aug 6, 2012

If I understand correcty this would require any json-ld parser to be a js-interpreter as well. This seems quite a strong requirement to me. It would also imply new security considerations for jso-ld documents.

@msporny
Copy link
Member Author

msporny commented Aug 6, 2012

@retobg There is no js-interpreter requirement here... the pre-processing step would be implemented in whatever language the API is implemented in.

@retog
Copy link

retog commented Aug 6, 2012

Ok, I must admit I haven't studied the API in detail. Such an extension would not fit into the declared scope of the API of allowing to "programmatically transforming JSON-LD documents in order to make them easier to work with" but it would enlarge the scope to transforming non JSLON-LD JSON documents. I don't know why we should want this, we should make JSON-LD itself easy to use and flexible enough to be close to a domain specific format in many cases.

I don't think that this would address #146. A resolution of #146 would broaden the possible serializations of RDF Graphs into JSON-LD allowing JSON-LD to be more similar to a dedicated JSON format for some common use cases

@gkellogg
Copy link
Member

gkellogg commented Aug 6, 2012

I think it's confusing to talk about this as a "pre-processing step", and should just consider that there are additional expansion rules. We already have expansion, which is a necessary part of most API calls. What we've been calling "pre-processing" should instead be part of the expansion algorithm, which might not have a counterpart in the compaction algorithm.

@lanthaler
Copy link
Member

RESOLVED: Do not support a pre-processing step option in the JSON-LD API to transform incoming JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants