To use the Javascript tree library DynaTree on my Visualforce page I create JSON data in its controller
List<DynaTreeNode> rootNodes = nodesByParentId.get(null).values();
dynaTreeJson = JSON.serialize(rootNodes);
dynaTreeJson = dynaTreeJson.replaceAll('select_X', 'select');
To construct the nodes I use this Apex class
public virtual class DynaTreeNode {
//...
public Boolean select_X = false;
public Boolean hideCheckbox = false;
}
The problem is that the Javascript expect a property called select which I cannot use as a name in Apex as it is a reserved (SOQL) keyword. According to this answer I prefixed it with _X and do a replaceAll() on the output.
The problem is that I now run into expeception when used on large JSON strings.
System.LimitException: Regex too complicated Error is in expression