/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */
package foam.lib.json;

import foam.lib.parse.*;
import foam.core.X;

public class UnknownFObjectParser implements Parser {

  public PStream parse(PStream ps, ParserContext x) {
    ps = ps.apply(new Whitespace(), x);
    if ( ps == null ) return null;

    StringBuilder sb = new StringBuilder();

    while( ps.valid() ) {
      sb.append(ps.head());
      ps = ps.tail();
    }

    UnknownFObject unknownFObject = ((X)x.get("x")).create(UnknownFObject.class);
    unknownFObject.setJson(sb.toString());

    return ps.setValue(unknownFObject);
  }
}
@@ -371,16 +371,44 @@
  null;%0A%0A
+    //TODO: use ThreadLocal%0A
     Stri
@@ -447,34 +447,253 @@
 ();%0A
-%0A    while( ps.valid() ) %7B
+    int count = 1;%0A    char head;%0A%0A    sb.append(ps.head());%0A    ps = ps.tail();%0A    while( ps.valid() && count != 0 ) %7B%0A      head = ps.head();%0A      if ( head == '%7B') %7B%0A        count++;%0A      %7D else if ( head == '%7D') %7B%0A        count--;%0A      %7D
 %0A   
@@ -701,33 +701,28 @@
   sb.append(
-ps.
 head
-()
 );%0A      ps 
@@ -788,17 +788,17 @@
 )x.get(%22
-x
+X
 %22)).crea
@@ -866,17 +866,16 @@
 ing());%0A
-%0A
     retu

fix bug