-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.js
More file actions
39 lines (31 loc) · 813 Bytes
/
Copy pathjson.js
File metadata and controls
39 lines (31 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/javascript/blob/master/LICENSE
*/
// json
// script with methods related to json format
// import
import { Str } from '../index.js';
// export
export default {
// encode
// encode une valeur en json
encode: function(value)
{
return JSON.stringify(value);
},
// decode
// decode une valeur à partir d'un json
decode: function(value)
{
return JSON.parse(Str.typecheck(value));
},
// recode
// encode et decode une valeur
// permet de faire des copies complêtes
recode: function(value)
{
return this.decode(this.encode(value));
}
}