Skip to content

Commit 22a33cc

Browse files
committed
fix deprecated JSON class
1 parent ee4cd93 commit 22a33cc

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

_test/renderer_plugin_edittable_json.test.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ function test_table() {
5252
);
5353

5454
$renderer = $this->render($input);
55-
$json = new JSON(JSON_LOOSE_TYPE);
5655

57-
$this->assertEquals($data, $json->decode($renderer->getDataJSON()));
58-
$this->assertEquals($meta, $json->decode($renderer->getMetaJSON()));
56+
$this->assertEquals($data, json_decode($renderer->getDataJSON(), true));
57+
$this->assertEquals($meta, json_decode($renderer->getMetaJSON(), true));
5958
}
6059

6160

action/editor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ public function editform(Doku_Event $event)
122122
*
123123
* @author Andreas Gohr <gohr@cosmocode,de>
124124
*/
125-
public function handle_table_post($event) {
125+
public function handle_table_post(Doku_Event $event)
126+
{
126127
global $TEXT;
127128
global $INPUT;
128-
if(!$INPUT->post->has('edittable_data')) return;
129+
if (!$INPUT->post->has('edittable_data')) return;
129130

130-
$json = new JSON(JSON_LOOSE_TYPE);
131-
$data = $json->decode($INPUT->post->str('edittable_data'));
132-
$meta = $json->decode($INPUT->post->str('edittable_meta'));
131+
$data = json_decode($INPUT->post->str('edittable_data'), true);
132+
$meta = json_decode($INPUT->post->str('edittable_meta'), true);
133133

134134
$TEXT = $this->build_table($data, $meta);
135135
}

renderer/json.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class renderer_plugin_edittable_json extends renderer_plugin_edittable_inverse {
3535
* @return array
3636
*/
3737
public function getDataJSON() {
38-
$json = new JSON();
39-
return $json->encode($this->tdata);
38+
return json_encode($this->tdata);
4039
}
4140

4241
/**
@@ -45,8 +44,7 @@ public function getDataJSON() {
4544
* @return array
4645
*/
4746
public function getMetaJSON() {
48-
$json = new JSON();
49-
return $json->encode($this->tmeta);
47+
return json_encode($this->tmeta);
5048
}
5149

5250
// renderer functions below

0 commit comments

Comments
 (0)