Permalink
Browse files

detects the parent keys woo

  • Loading branch information...
0 parents commit f4986925cdc78b80b54c2855fd71c665e5f04a02 @substack committed Jul 19, 2011
Showing with 41 additions and 0 deletions.
  1. +5 −0 ex.js
  2. +32 −0 index.js
  3. +4 −0 stub.json
5 ex.js
@@ -0,0 +1,5 @@
+var fs = require('fs');
+var jsup = require('./');
+
+var src = fs.readFileSync(__dirname + '/stub.json', 'utf8');
+jsup(src);
@@ -0,0 +1,32 @@
+var burrito = require('burrito');
+
+module.exports = function (src) {
+ var self = {};
+ var nodes = [];
+
+ burrito('[\n' + src + '\n][0]', function (node) {
+ var p = node.parent();
+ if (p && p.name === 'object') {
+ var ix = this.path[ this.path.length - 2 ];
+ var key = p.value[0][ix][0];
+ console.log(key);
+ }
+ else if (p && p.name === 'array') {
+ }
+
+ nodes.push(node);
+ });
+
+ self.set = function (key, value) {
+
+ };
+
+ self.toString = self.stringify = function () {
+ };
+
+ self.inspect = function () {
+ return 'lul'
+ };
+
+ return self;
+};
@@ -0,0 +1,4 @@
+{
+ "a" : [1, 2],
+ "b" : [ 3, 4 ]
+}

0 comments on commit f498692

Please sign in to comment.