.replaceAll("\\s+([:\\)\\(,;}{'\"])" , "$1") // Remove spaces
.replaceFirst("^[\\(]+(.*)[\\)]+$", "$1") // Remove ()
.replaceAll("\\([\"']([^\\)]+)[\"']\\)" , "($1)") // Remove quotes
- .replaceAll("[;,]+([\\w-\\$]+):", ";$1:") // Change comma by semicolon
+ .replaceAll("[;,]+([\\w-\\$]+:|$)", ";$1") // Change comma by semicolon
.replaceAll("([^,;])([\\]}])", "$1;$2") // Put control semicolon used below
.replaceAll(":\\s*[\"']?([^;\\{\\}\\[\\]\"']*)[\"']?\\s*([;,]+|$)", ":\"$1\";") // put quotes to all values (even empty)
.replaceAll("[;,]+([\\w-]+):", ";$1:") // Change semicolon by comma
.replaceAll("[;,]+([\\]\\}]|$)", "$1") // remove endings
;
ret = ret.matches("(^[\\[\\{].*[\\]\\}]$)") ? ret : "{" + ret + "}";
+ System.out.println(s + " -> " + ret);
return ret;
}
assertEquals("{\"width\":\"\",\"top\":\"\"}", Properties
.wrapPropertiesString("width: '' ; top:'' ;"));
assertEquals("{\"border-left\":\"solid\"}", Properties
- .wrapPropertiesString("border-left: solid"));
+ .wrapPropertiesString("border-left: solid,"));
assertEquals("[{\"a\":1,\"b\":{\"a\":2,\"b\":{\"a\":3}},\"u\":\"url\",\"d\":2,\"t\":[\"hola\",\"adios\"],\"z\":true}]", Properties
.wrapPropertiesString("[{a:1, b:{a:2,b:{a:3}},u:url, d:'2','t':['hola','adios'], 'z': true}]"));
assertEquals("{\"$x\":22.60,\"$y\":\".0\",\"h\":\"#y\"}", Properties