JavaScript对象查询语言 SpahQL

openkk 12年前

SpahQL是一种查询语言和数据操作JS类库,用于处理Javascript对象。

var data = {"a": {"foo": "bar-a", "bar": "baz-a"}, "b": {"foo": "bar-b", "bar": "baz-b", "moo": "huzzah"}},   db = SpahQL.db(data);    Now you have access to an xpath-like syntax for accessing data:    var foos = db.select("//foo");  return foos.values(); //-> ["bar-a", "bar-b"]    And also making assertions about data:    db.assert("/a/foo == /b/foo"); //-> true  db.assert("/a/foo == //moo"); //-> false    A jQuery-like syntax for modifying your data:    db.select("/*/*").replaceAll("BEHOLD");  return data; //-> {"a": {"foo": "BEHOLD", "bar": "BEHOLD"}, "b": {"foo": "BEHOLD", "bar": "BEHOLD", "moo": "BEHOLD"}}

项目主页:http://www.open-open.com/lib/view/home/1337591666667