static private IsString ( JToken v ) : bool | ||
v | JToken | the value to check. |
return | bool |
/// <summary>parses a @context object and sets any namespaces found within it</summary> /// <param name="context"></param> public virtual void ParseContext(JObject context) { foreach (string key in context.GetKeys()) { JToken val = context[key]; if ("@vocab".Equals(key)) { if (val.IsNull() || JsonLdUtils.IsString(val)) { SetNamespace(string.Empty, (string)val); } } else { // TODO: the context is actually invalid, should we throw an // exception? if ("@context".Equals(key)) { // go deeper! ParseContext((JObject)context["@context"]); } else { if (!JsonLdUtils.IsKeyword(key)) { // TODO: should we make sure val is a valid URI prefix (i.e. it // ends with /# or ?) // or is it ok that full URIs for terms are used? if (val.Type == JTokenType.String) { SetNamespace(key, (string)context[key]); } else { if (JsonLdUtils.IsObject(val) && ((JObject)val).ContainsKey("@id" )) { SetNamespace(key, (string)((JObject)val)["@id"]); } } } } } } }
/// <summary>parses a @context object and sets any namespaces found within it</summary> /// <param name="context"></param> public virtual void ParseContext(JObject context) { foreach (var key in context.GetKeys()) { var val = context[key]; if ("@vocab".Equals(key)) { if (val.IsNull() || JsonLdUtils.IsString(val)) { SetNamespace(string.Empty, (string)val); } } else { // TODO: the context is actually invalid, should we throw an // exception? if ("@context".Equals(key)) { // go deeper! ParseContext((JObject)context["@context"]); } else { if (!JsonLdUtils.IsKeyword(key)) { if (val.Type == JTokenType.String) { SetNamespace(key, (string)context[key]); } else { if (JsonLdUtils.IsObject(val) && ((JObject)val).ContainsKey("@id" )) { SetNamespace(key, (string)((JObject)val)["@id"]); } } } } } } }