0

I'm im using zendframework/zend-diactoros with Laravel. I have a problem when I sent json data like

{
    "data": {
        "value": ""
    }
}

Then, in controller

// @var $request Psr\Http\Message\ServerRequestInterface
var_dump($request->getParsedBody())
/*
array:1 [
  "data" => array:1 [
      "value" => null // I expect "value" => ""
  ]
]

More examples:

I sent

{
    "data": {
        "value": null
    }
}

var_dump

var_dump($request->getParsedBody())
/*
array:1 [
  "data" => array:1 [
      "value" => null // that's OK
  ]
]

I sent

{
    "data": {
        "value": "x"
    }
}

var_dump

var_dump($request->getParsedBody())
/*
array:1 [
  "data" => array:1 [
      "value" => "x"  // that's OK
  ]
]

Only first example has a problem, but I dont have any idea if this is correct. Maybe exists a way to dump exact received data with this PSR7 library.

pablorsk
  • 3,861
  • 1
  • 32
  • 37
  • 1
    You should provide some *valid* example JSON that reproduces the issue. What you have provided is not at all parseable JSON. – Sammitch Jun 20 '18 at 22:08
  • sorry @Sammitch, json expamples updated (I forgot do it when simplify the example). – pablorsk Jun 20 '18 at 22:41

0 Answers0