10 examples of 'typescript import json' in JavaScript

Every line of 'typescript import json' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
16function importJson() {
17 try {
18 return require("./config.json")
19 } catch (ex) {
20 return {}
21 }
22}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

37function importFromJson(json){
38 scope.$parent.paper.clear();
39 // Deserialize from json
40 scope.$parent.paper.fromJSON(json, function (el, data){
41 // Restore properties
42 el.height = data.height;
43 el.width = data.width;
44 el.rotation = data.rotation;
45 el.opacity = data.opacity;
46 el.keepratio = data.keepratio;
47 el.mirror = data.mirror;
48
49 // Restore event handlers
50 if(data.background){
51 scope.$parent.initBackground(el);
52 } else if(data.ft){
53 el.mousedown(scope.$parent.elementMouseDown);
54
55 // Restore freeTransform
56 var ft = scope.$parent.paper.freeTransform(el, {}, function(ft, events) {
57 scope.$parent.setCurrent(ft.subject);
58 scope.$parent.handleFtChanged(ft, events);
59 });
60
61 el.ft = ft;
62 el.ft.attrs = data.ft;
63
64 hElement.setHeight(el, ft.attrs.y);
65 hElement.setWidth(el, ft.attrs.x);
66 hElement.setRotation(el, ft.attrs.rotate);
67 hElement.setKeepRatio(el);
68
69 ft.setOpts({'drag':['self']});
70
71 if(el.type === 'text'){
72 ft.setOpts({distance: scope.$parent.constants.ELEMENT_TEXT_HANDLE_DISTANCE});
73 el.inited = true;
74 }
75
76 ft.handles.y.line.handle=true;
77 ft.handles.x.line.handle=true;
78 ft.handles.x.disc.handle=true;
79 ft.handles.y.disc.handle=true;
80
81 hElement.handles(el);
82 }
83
84 return el;
85 });
86 $timeout(scope.$parent.unfocus, 1);
87}
10function importFile(path) {
11 try {
12 const content = fs.readFileSync(path, { encoding: 'utf8' });
13 return JSON.parse(content);
14 } catch (error) {
15 /* eslint-disable no-console */
16 console.error('could not parse ', path, 'as JSON');
17 console.error(error);
18 /* eslint-enable no-console */
19 }
20
21 return null;
22}
6function importAll(r) {
7 r.keys().forEach(function (key) {
8 const fileName = key.split('/').pop().replace(/\..+$/, '');
9 cache[fileName] = r(key)
10 });
11}
28function importAll (r) {
29 let images = {};
30 r.keys().forEach((item) => {
31 images[item.replace('./', '')] = r(item);
32 });
33 return images;
34}
70function _load_import() {
71 return _import = _interopRequireWildcard(require('./import.js'));
72}
742value: function importJSON() {
743 var data = this.cache.json.get('data');
744 this.path = this.path.fromJSON(data);
745 this.draw();
746}
11export function detectImport() {
12 let str
13 let json = ''
14 while ((str = Zotero.read(chunkSize)) !== false) {
15 json += str
16 if (json[0] !== '{') return false
17 }
18
19 let data
20 try {
21 data = JSON.parse(json)
22 } catch (err) {
23 return false
24 }
25
26 if (!data.config || (data.config.id !== Translator.header.translatorID)) return false
27 return true
28}
34public import(stream: EventEmitter): EventEmitter {
35 const output = new PassThrough({ objectMode: true });
36 stream.on('error', (error) => parsed.emit('error', error));
37 stream.on('data', (data) => output.write(data));
38 stream.on('end', () => output.emit('end'));
39 const parsed = output.pipe(new JsonLdSerializer(this.options));
40 return parsed;
41}
216value: function _import(pathToModule) {
217 return require(this.root(pathToModule));
218}

Related snippets