web.Json(source : str, ttl: num) : any
Parse JSON source into a DekiScript data-structure.
Usage Restrictions
8.08 or later.
Parameters
| Name | Type | Description |
| source | str | source text or source URI |
| ttl | num | (optional, range: 60 - 86400, default: 300) caching durations in seconds |
Result
If the source argument is not a URI, web.json works the same as json.parse. Otherwise, web.json fetches the data from the URI using web.text and parses it using json.parse.
NOTE: all web.* functions are limited to reading at most 500KB of data from a URI.
Samples
| | Output |
| To convert JSON into a DekiScript data-structure: {{ web.json("{ hello: 'world' }") }} | | { hello : "world" } |
| To fetch JSON from a URI and convert it into a DekiScript data-structure: {{ web.json("http://api.crunchbase.com/v/1/company/twitter.js") }} | | ")" expected: string.deserialize(value), line 1, column 9 (click for details)Callstack:
at en/docs/DekiScript/Reference/DekiScript_Functions_and_Variables/Web.Json
at web.json
MindTouch.Deki.Script.Compiler.DekiScriptParserException: ")" expected: string.deserialize(value), line 1, column 9
at MindTouch.Deki.Script.Compiler.Errors.SynErr (System.String origin, Int32 line, Int32 col, Int32 n) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.SynErr (Int32 n) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Expect (Int32 n) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Primary (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Unary (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.MulExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.AddExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.ConcatExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.RelExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.EqlExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.AndExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.OrExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.NullCoalescingExpr (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.TernaryExpression (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Expression (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Statements (MindTouch.Deki.Script.Expr.DekiScriptExpression& expr) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.DekiScript () [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.Parser.Parse () [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptParser.Parse (Location location, System.String source) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Runtime.Library.DekiScriptLibrary.StringDeserialize (System.String value, MindTouch.Deki.Script.DekiScriptRuntime runtime) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Runtime.Library.DekiScriptLibrary.JsonParse (System.String value, MindTouch.Deki.Script.DekiScriptRuntime runtime) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Runtime.Library.DekiScriptLibrary.WebJson (System.String source, Nullable`1 ttl, Nullable`1 nilIfMissing, MindTouch.Deki.Script.DekiScriptRuntime runtime) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 |
Is the dekiscript data structure mentioned is XHTML, XML, etc? If I have some json data from a ning site that I want to POST (http://developer.mindtouch.com/en/ref/MindTouch_API/POST:pages//%7Bpageid%7D//contents) to pages in MindTouch, does that mean I have to go through the conversion to dekiscript data structure first?
Any pointers on how you'd approach this? Can desktop suite help?
Cheers, Nathan