Skip to content

RequestBodyParser does not support scalar JSON values (bool, int, float, string) #41

Description

@Sluchainik

What steps will reproduce the problem?

  1. Use the Yiisoft\Request\Body\Parser\JsonParser to parse a JSON body containing scalar values such as true, 42, 3.14, or "hello".
  2. Observe that the Yiisoft\Request\Body\Parser\JsonParser does not handle these scalar values correctly.

What is the expected result?

The RequestBodyParser should correctly parse JSON bodies containing scalar values (boolean, integer, float, string) and return these values without errors.

json_decode('true');   // Expected result: true (boolean)
json_decode('42');     // Expected result: 42 (integer)
json_decode('3.14');   // Expected result: 3.14 (float)
var_dump(json_decode('-1e3')); // Expected -1000 (float)
json_decode('"hello"');// Expected result: "hello" (string)

What do you get instead?

The RequestBodyParser fails to handle JSON bodies with scalar values and does not return the expected result. Instead, it only supports objects and arrays.

Q A
Version 1.0.?
PHP version any
Operating system any

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions