350-401 · Question #1081
Drag and Drop Question Drag and drop the code snippets from the bottom onto the blanks in the script to convert a Python object into a compact JSON object by removing space characters. Not all options
The correct answer is json_encode; $inputArray; $encodedJSON. The correct arrangement uses json_encode as the function to convert a PHP object/array into a JSON string, $inputArray as the source data being encoded, and $encodedJSON as the variable storing the resulting compact JSON output. To remove space characters and produce compact JSON
Question
Drag and Drop Question Drag and drop the code snippets from the bottom onto the blanks in the script to convert a Python object into a compact JSON object by removing space characters. Not all options are used. Answer:
Exhibits
Answer Area
Drag items
Correct arrangement
- json_encode
- $inputArray
- $encodedJSON
Explanation
The correct arrangement uses json_encode as the function to convert a PHP object/array into a JSON string, $inputArray as the source data being encoded, and $encodedJSON as the variable storing the resulting compact JSON output. To remove space characters and produce compact JSON, json_encode($inputArray, JSON_UNESCAPED_SLASHES) or similar flags are used, with the result assigned to $encodedJSON. This follows the standard PHP pattern: $encodedJSON = json_encode($inputArray, JSON_PRETTY_PRINT ^ JSON_PRETTY_PRINT) or with JSON_UNESCAPED_UNICODE to strip whitespace.
Topics
Community Discussion
No community discussion yet for this question.

