a:8:{s:9:"#provides";s:16:"dojox.json.query";s:9:"#resource";s:13:"json/query.js";s:3:"end";a:1:{s:7:"summary";s:0:"";}s:5:"start";a:1:{s:7:"summary";s:0:"";}s:16:"value.__included";a:2:{s:7:"private";b:1;s:7:"summary";s:0:"";}s:16:"dojox.json.query";a:7:{s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"query";a:2:{s:4:"type";s:6:"String";s:7:"summary";s:12:"Query string";}s:3:"obj";a:3:{s:8:"optional";b:1;s:4:"type";s:6:"Object";s:7:"summary";s:23:"Target of the JSONQuery";}}s:6:"source";s:3897:" var depth = 0; var str = []; query = query.replace(/"(\\.|[^"\\])*"|'(\\.|[^'\\])*'|[\[\]]/g,function(t){ depth += t == '[' ? 1 : t == ']' ? -1 : 0; // keep track of bracket depth return (t == ']' && depth > 0) ? '`]' : // we mark all the inner brackets as skippable (t.charAt(0) == '"' || t.charAt(0) == "'") ? "`" + (str.push(t) - 1) :// and replace all the strings t; }); var prefix = ''; function call(name){ // creates a function call and puts the expression so far in a parameter for a call prefix = name + "(" + prefix; } function makeRegex(t,a,b,c,d,e,f,g){ // creates a regular expression matcher for when wildcards and ignore case is used return str[g].match(/[\*\?]/) || f == '~' ? "/^" + str[g].substring(1,str[g].length-1).replace(/\\([btnfr\\"'])|([^\w\*\?])/g,"\\$1$2").replace(/([\*\?])/g,"[\\w\\W]$1") + (f == '~' ? '$/i' : '$/') + ".test(" + a + ")" : t; } query.replace(/(\]|\)|push|pop|shift|splice|sort|reverse)\s*\(/,function(){ throw new Error("Unsafe function call"); }); query = query.replace(/([^=]=)([^=])/g,"$1=$2"). // change the equals to comparisons replace(/@|(\.\s*)?[a-zA-Z\$_]+(\s*:)?/g,function(t){ return t.charAt(0) == '.' ? t : // leave .prop alone t == '@' ? "$obj" :// the reference to the current object (t.match(/:|^(\$|Math|true|false|null)$/) ? "" : "$obj.") + t; // plain names should be properties of root... unless they are a label in object initializer }). replace(/\.?\.?\[(`\]|[^\]])*\]|\?.*|\.\.([\w\$_]+)|\.\*/g,function(t,a,b){ var oper = t.match(/^\.?\.?(\[\s*\^?\?|\^?\?|\[\s*==)(.*?)\]?$/); // [?expr] and ?expr and [=expr and =expr if(oper){ var prefix = ''; if(t.match(/^\./)){ // recursive object search call("expand"); prefix = ",true)"; } call(oper[1].match(/\=/) ? "dojo.map" : oper[1].match(/\^/) ? "distinctFilter" : "dojo.filter"); return prefix + ",function($obj){return " + oper[2] + "})"; } oper = t.match(/^\[\s*([\/\\].*)\]/); // [/sortexpr,\sortexpr] if(oper){ // make a copy of the array and then sort it using the sorting expression return ".concat().sort(function(a,b){" + oper[1].replace(/\s*,?\s*([\/\\])\s*([^,\\\/]+)/g,function(t,a,b){ return "var av= " + b.replace(/\$obj/,"a") + ",bv= " + b.replace(/\$obj/,"b") + // FIXME: Should check to make sure the $obj token isn't followed by characters ";if(av>bv||bv==null){return " + (a== "/" ? 1 : -1) +";}\n" + "if(bv>av||av==null){return " + (a== "/" ? -1 : 1) +";}\n"; }) + "return 0;})"; } oper = t.match(/^\[(-?[0-9]*):(-?[0-9]*):?(-?[0-9]*)\]/); // slice [0:3] if(oper){ call("slice"); return "," + (oper[1] || 0) + "," + (oper[2] || 0) + "," + (oper[3] || 1) + ")"; } if(t.match(/^\.\.|\.\*|\[\s*\*\s*\]|,/)){ // ..prop and [*] call("expand"); return (t.charAt(1) == '.' ? ",'" + b + "'" : // ..prop t.match(/,/) ? "," + t : // [prop1,prop2] "") + ")"; // [*] } return t; }). replace(/(\$obj\s*((\.\s*[\w_$]+\s*)|(\[\s*`([0-9]+)\s*`\]))*)(==|~)\s*`([0-9]+)/g,makeRegex). // create regex matching replace(/`([0-9]+)\s*(==|~)\s*(\$obj\s*((\.\s*[\w_$]+)|(\[\s*`([0-9]+)\s*`\]))*)/g,function(t,a,b,c,d,e,f,g){ // and do it for reverse = return makeRegex(t,c,d,e,f,g,b,a); }); query = prefix + (query.charAt(0) == '$' ? "" : "$") + query.replace(/`([0-9]+|\])/g,function(t,a){ //restore the strings return a == ']' ? ']' : str[a]; }); // create a function within this scope (so it can use expand and slice) var executor = eval("1&&function($,$1,$2,$3,$4,$5,$6,$7,$8,$9){var $obj=$;return " + query + "}"); for(var i = 0;i, <=, >=, != - These operators behave just as they do in JavaScript. dojox.json.query(queryString,object) and dojox.json.query(queryString)(object) always return identical results. The first one immediately evaluates, the second one returns a function that then evaluates the object.";s:7:"returns";s:138:"we mark all the inner brackets as skippable|leave .prop alone|FIXME: Should check to make sure the $obj token isn't followed by characters";s:8:"examples";a:3:{i:0;s:62:" dojox.json.query("foo",{foo:"bar"}) This will return "bar".";i:1;s:312:" evaluator = dojox.json.query("?foo='bar'&rating>3"); This creates a function that finds all the objects in an array with a property foo that is equals to "bar" and with a rating property with a value greater than 3. evaluator([{foo:"bar",rating:4},{foo:"baz",rating:2}]) This returns: {foo:"bar",rating:4}";i:2;s:241:" evaluator = dojox.json.query("$[?price<15.00][\rating][0:10]"); This finds objects in array with a price less than 15.00 and sorts then by rating, highest rated first, and returns the first ten items in from this filtered and sorted list.";}}s:10:"dojox.json";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:5:"dojox";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}