yiisoft / yiisoft/request-body-parser
RequestBodyParser does not support scalar JSON values (bool, int, float, string)
Open
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?
- Use the
Yiisoft\Request\Body\Parser\JsonParserto parse a JSON body containing scalar values such astrue,42,3.14, or"hello". - Observe that the
Yiisoft\Request\Body\Parser\JsonParserdoes 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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