//>>built // wrapped by build app define("dojox/jsonPath/query", ["dijit","dojo","dojox"], function(dijit,dojo,dojox){ dojo.provide("dojox.jsonPath.query"); dojox.jsonPath.query = function(/*Object*/obj, /*String*/expr, /*Object*/arg){ // summaRy // Perform jsonPath query `expr` on javascript object or json string `obj` // obj - object || json string to perform query on // expr - jsonPath expression (string) to be evaluated // arg - {}special arugments. // resultType: "VALUE"||"BOTH"||"PATH"} (defaults to value) // evalType: "RESULT"||"ITEM"} (defaults to ?) var re = dojox.jsonPath._regularExpressions; if (!arg){arg={};} var strs = []; function _str(i){ return strs[i];} var acc; if (arg.resultType == "PATH" && arg.evalType == "RESULT") throw Error("RESULT based evaluation not supported with PATH based results"); var P = { resultType: arg.resultType || "VALUE", normalize: function(expr){ var subx = []; expr = expr.replace(/'([^']|'')*'/g, function(t){return "_str("+(strs.push(eval(t))-1)+")";}); var ll = -1; while(ll!=subx.length){ ll=subx.length;//TODO: Do expression syntax checking expr = expr.replace(/(\??\([^\(\)]*\))/g, function($0){return "#"+(subx.push($0)-1);}); } expr = expr.replace(/[\['](#[0-9]+)[\]']/g,'[$1]') .replace(/'?\.'?|\['?/g, ";") .replace(/;;;|;;/g, ";..;") .replace(/;$|'?\]|'$/g, ""); ll = -1; while(ll!=expr){ ll=expr; expr = expr.replace(/#([0-9]+)/g, function($0,$1){return subx[$1];}); } return expr.split(";"); }, asPaths: function(paths){ for (var j=0;j