yiisoft / yiisoft/request-body-parser

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

Open
#41 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:bug
Dominant language
PHP
Stars
18
Forks
9
Avg merge
50m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Yiisoft\Request\Body\Parser\JsonParser entry point and inspect how it currently handles JSON objects and arrays. Verify behavior for true, 42, 3.14, -1e3, and "hello"; done means each scalar value is returned correctly without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.