replacement for PHP json_encode() with attritue and textNode fixes and compacter JSON format