134 | function jsonParser(json) { |
135 | |
136 | n = 2; |
137 | |
138 | json.forEach(function(root){ |
139 | root.child.forEach(function(child){ |
140 | |
141 | if(root.tags.length < 1){ |
142 | child.indent = root.indent+n; |
143 | } |
144 | |
145 | else if(root.tags.length > 0 && root.tags[0].position == 0 && !root.content.match(/^\/\/\-*.*/)) { |
146 | child.indent = root.indent; |
147 | } |
148 | else if(root.tags.length > 0 && root.tags[0].position != 0 && !root.content.match(/^\/\/\-*.*/)) { |
149 | child.indent = root.indent+n; |
150 | } |
151 | |
152 | if(child.child.length > 0) |
153 | jsonParser([child]); |
154 | }); |
155 | }); |
156 | return json; |
157 | } |