I am using scalaj to make a Http post request
How can I pass lat,long and radius as arguments in the postData field
val result = Http("http:xxxx/xxx/xxxxx").postData("""{"latitude":"39.6270025","longitude":"-90.1994042","radius":"0"}""").asString
Why is the string passed in """json""" such a manner?
Based on the docs it looks like the postData function takes only array of bytes and string as argument.
So this is two questions at once. Let's start with the second one.
Scala allows special syntax for multiline string literals (or strings containing newlines, quotation marks and so on). So you can do
Now back to the main question
I suppose you are in this situation:
And you want to pass that into the
postData
function, mixed with some other maybe fixed strings.Well another feature Scala gives is so-called
string interpolation
. Easy exampleSo in your case you could do the same