Debian Codegraph @

jsonpickleJS/main.js

raw
1 /**
2 * jsonpickleJS -- interpretation of python jsonpickle in Javascript
3 * main.js -- main loader -- this should be the only file that most users care about.
4 *
5 * Copyright (c) 2014 Michael Scott Cuthbert and cuthbertLab
6 */
7
8 if (typeof jsonpickle == 'undefined') {
9 jsonpickle = {}; // global for now...
10 }
11
12 define(['./unpickler', './pickler', './util', './tags', './handlers'],
13 function(unpickler, pickler, util, tags, handlers) {
14 jsonpickle.pickler = pickler;
15 jsonpickle.unpickler = unpickler;
16 jsonpickle.util = util;
17 jsonpickle.tags = tags;
18 jsonpickle.handlers = handlers;
19
20 jsonpickle.encode = function (value, unpicklable, make_refs,
21 keys, max_depth, backend) {
22 if (unpicklable === undefined) {
23 unpicklable = true;
24 }
25 if (make_refs === undefined) {
26 make_refs = true;
27 }
28 if (keys === undefined) {
29 keys = false;
30 }
31 var options = {
32 unpicklable: unpicklable,
33 make_refs: make_refs,
34 keys: keys,
35 max_depth: max_depth,
36 backend: backend,
37 };
38 return pickler.encode(value, options);
39 };
40
41
42 jsonpickle.decode = function (string, backend, keys) {
43 if (keys === undefined) {
44 keys = false;
45 }
46 return unpickler.decode(string, backend, keys);
47 };
48 return jsonpickle;
49 });