rfc:json_encode_indentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:json_encode_indentation [2021/06/03 13:57] โ€“ tdgrootrfc:json_encode_indentation [2021/06/03 15:23] โ€“ tdgroot
Line 3: Line 3:
   * Date: 2021-06-03   * Date: 2021-06-03
   * Author: Timon de Groot, tdegroot96@gmail.com   * Author: Timon de Groot, tdegroot96@gmail.com
 +  * Implementation: https://github.com/php/php-src/pull/7093
   * Status: Draft   * Status: Draft
  
Line 18: Line 19:
 $data = [ $data = [
     'key' => 4,     'key' => 4,
-    'other_key' => [0, 1, 2, 3]+    'other_key' => [2]
 ]; ];
  
 +echo json_encode(['behavior' => 'default'], JSON_PRETTY_PRINT) . PHP_EOL;
 echo json_encode($data, JSON_PRETTY_PRINT, 512, 2) . PHP_EOL; echo json_encode($data, JSON_PRETTY_PRINT, 512, 2) . PHP_EOL;
-echo json_encode($data, JSON_PRETTY_PRINT, 512, '๐Ÿš€๐Ÿš€') . PHP_EOL;+echo json_encode(['unicode' => "supported"], JSON_PRETTY_PRINT, 512, '๐Ÿš€๐Ÿš€') . PHP_EOL;ย 
 +echo json_encode(['tabs' => "better"], JSON_PRETTY_PRINT, 512, "\t") . PHP_EOL;
  
 ?> ?>
 </code> </code>
  
-<code>+<code json>ย 
 +{ย 
 +    "behavior": "default"ย 
 +}
 { {
   "key": 4,   "key": 4,
   "other_key": [   "other_key": [
-    0,ย +    2
-    1,ย +
-    2,ย +
-    3+
   ]   ]
 } }
 { {
-๐Ÿš€"key": 4,ย +๐Ÿš€๐Ÿš€"unicode": "supported"ย 
-๐Ÿš€"other_key": [ย +}ย 
-๐Ÿš€๐Ÿš€0,ย +{ย 
-๐Ÿš€๐Ÿš€1,ย + "tabs": "better"
-๐Ÿš€๐Ÿš€2,ย +
-๐Ÿš€๐Ÿš€3ย +
-๐Ÿš€]+
 } }
 </code> </code>
rfc/json_encode_indentation.txt ยท Last modified: 2022/07/19 15:23 by cmb

๏ปฟ