Update to latest jsonld.js.
--- a/playground/jsonld.js Sun Apr 22 20:26:51 2012 -0400
+++ b/playground/jsonld.js Mon Apr 23 15:36:06 2012 -0400
@@ -136,6 +136,11 @@
compacted = [compacted];
}
+ // follow @context key
+ if(_isObject(ctx) && '@context' in ctx) {
+ ctx = ctx['@context'];
+ }
+
// build output context
ctx = _clone(ctx);
if(!_isArray(ctx)) {
@@ -3385,6 +3390,7 @@
else if(_isObject(input)) {
for(var key in input) {
if(key !== '@context') {
+ findUrls(input[key], replace);
continue;
}
@@ -3400,7 +3406,7 @@
ctx[i] = urls[ctx[i]];
}
// unresolved @context found
- else {
+ else if(!(ctx[i] in urls)) {
urls[ctx[i]] = {};
}
}
@@ -3413,7 +3419,7 @@
input[key] = urls[ctx];
}
// unresolved @context found
- else {
+ else if(!(ctx in urls)) {
urls[ctx] = {};
}
}
@@ -3480,7 +3486,8 @@
errors.push(err);
}
else {
- // FIXME: needs to recurse to resolve URLs in the result
+ // FIXME: needs to recurse to resolve URLs in the result, and
+ // detect cycles, and limit recursion
urls[url] = ctx['@context'] || {};
}