javascript - How to pass the Scala Map[String,Map[String,String]] to Js Object -
i wanted pass scala map values javascript json onject in play framework view
i "syntaxerror: json.parse: unexpected character @ line 1 column 10 of json data" when check following code
val maptobepasstojs = map( "cg1" -> map( "path" -> "/var/logs/cdr1/cdr", "name" -> "cg-1" ), "cg2" -> map( "path" -> "/var/logs/cdr2/cdr", "name" -> "cg-2" ), "cg3" -> map( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-3" ), "cg4" -> map( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-4" ) ) <script type="text/javascript"> var achartlist = jquery.parsejson("@jsonobject(maptobepasstojs).tostring()".replace(/"/g,'"')); </script>
anyone please me
as want json result why not using json.obj()
. following structure then.
val maptobepasstojs = json.obj( "cg1" -> json.obj( "path" -> "/var/logs/cdr1/cdr", "name" -> "cg-1" ), "cg2" -> json.obj( "path" -> "/var/logs/cdr2/cdr", "name" -> "cg-2" ), "cg3" -> json.obj( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-3" ), "cg4" -> json.obj( "path" -> "/var/logs/cdr3/cdr", "name" -> "cg-4" ) )
Comments
Post a Comment