rfc:parse_request_body_in_json
Differences
This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
rfc:parse_request_body_in_json [2018/10/02 15:59] – created jhdxr | rfc:parse_request_body_in_json [2018/10/02 16:37] – jhdxr | ||
---|---|---|---|
Line 11: | Line 11: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | It's very common for javascript library to send JSON payload now, however, PHP doesn' | + | It's very common for javascript library to send JSON payload now, however, PHP doesn' |
+ | |||
+ | For example, | ||
+ | < | ||
+ | curl -i -H " | ||
+ | </ | ||
+ | will get | ||
+ | <code php> | ||
+ | var_dump($_POST); | ||
+ | /* | ||
+ | array(2) { | ||
+ | [" | ||
+ | string(3) " | ||
+ | [" | ||
+ | int(456) | ||
+ | } | ||
+ | */ | ||
+ | </ | ||
+ | |||
+ | Some edge cases: | ||
+ | - illegal data: If the payload cannot be decoded, '' | ||
+ | - scalar type value: If the payload is a simple scalar type value, like numbers, string, TRUE or FALSE, '' | ||
+ | - large number value: Large number will be stored as string, which means '' | ||
rfc/parse_request_body_in_json.txt · Last modified: 2018/10/02 16:57 by jhdxr