Alternatively, use string interpolation:
scala> val foo = 42
foo: Int = 42
scala> s"""{"foo":$foo}"""
res0: String = {"foo":42}
(note the 's'.) Rex is absolutely right about the effects of
triple-quotes, also.
PS: You might also consider a JSON lib. It should handle things like
escaping quotes inside variables like 'foo' or 'timestamp' and lots of
other gotchas.
On 06/23/2016 01:59 PM, Rex Kerr wrote:
> You need to open/close triple quotes, not single quotes, around the
> variable name.
> """blah""" + foo + """lalala"""
>
> Everything inside triple quotes is considered to be a literal string.
>
> --Rex
>
>
> On Wed, Jun 22, 2016 at 2:05 AM, <
pmour...@gmail.com
> <mailto:
pmour...@gmail.com>> wrote:
>
> |importjava.util.Calendarvaltimestamp =Calendar.getInstance.getTime
> \\I have defined the timestamp variable|
>
>
> Following my request which i wanted to pass the runtime datetime value.
>
>
> |.exec(http("request_6").post("/abcd/projects").headers(headers_29).formParam("Id","5").formParam("extra","""{"inputproname":"+timestamp+","textareadesc":"""))\\passing
> the same timestamp here|
>
>
> Scala script has been successfully executed but it created as name
> with << +timestamp+ >> instead of actual timestamp value
>
>
> So can anyone tell me what am i doing wrong here? how to pass the
> time timestamp variable ???
>
>
> Your help would be much appreciated.
>
>
>
> Thanks in advance
>
> Praveen
>
> --
> You received this message because you are subscribed to the Google
> Groups "scala-user" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to
scala-user+...@googlegroups.com
> <mailto:
scala-user+...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "scala-user" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
scala-user+...@googlegroups.com
> <mailto:
scala-user+...@googlegroups.com>.
--