amnaredo / test

0 stars 0 forks source link

JsObject Formater #157

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago

First of all, congrats for your work. We are using a lot of it in my company.

I don't know if there's already a way to do this but it will be super cool if we can format JsObjects.

intruderOut.expectMsgPF() {
   case msg: JsObject => pprint.log(msg)
}

current output:

{"id":"562c9f72-5f4d-4868-8c39-9de450076772","type":"error","data":[{"code":3002,"message":"talker <YnPC7m> does not have permissions for conversation <069ba3ee-ceb8-4fd9-8063-67fe8a9f5718>"}]}

super cool output:

{
    "id":"562c9f72-5f4d-4868-8c39-9de450076772",
    "type":"error",
    "data":
    [
        {
             "code":3002,
             "message":"talker <YnPC7m> does not have permissions for conversation <069ba3ee-ceb8-4fd9-8063-67fe8a9f5718>"
        }
    ]
}

ID: 132 Original Author: sergigp

amnaredo commented 3 years ago

From the docs

// You can pass in an `indent` parameter to format it nicely
write(Array(1, 2, 3), indent = 4)  -->
  """[
    |    1,
    |    2,
    |    3
    |]""".stripMargin

Original Author: lihaoyi