mirror of https://github.com/OpenVidu/openvidu.git
openvidu-testapp: improved JSON stringify without circular dependencies
parent
bd83a1993b
commit
928514d57c
File diff suppressed because it is too large
Load Diff
|
@ -15,6 +15,7 @@
|
||||||
"colormap": "2.3.1",
|
"colormap": "2.3.1",
|
||||||
"core-js": "3.4.7",
|
"core-js": "3.4.7",
|
||||||
"hammerjs": "2.0.8",
|
"hammerjs": "2.0.8",
|
||||||
|
"json-stringify-safe": "^5.0.1",
|
||||||
"openvidu-browser": "2.17.0",
|
"openvidu-browser": "2.17.0",
|
||||||
"openvidu-node-client": "2.17.0",
|
"openvidu-node-client": "2.17.0",
|
||||||
"rxjs": "6.5.3",
|
"rxjs": "6.5.3",
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { OpenviduParamsService } from '../../services/openvidu-params.service';
|
||||||
import { TestFeedService } from '../../services/test-feed.service';
|
import { TestFeedService } from '../../services/test-feed.service';
|
||||||
import { SessionConf } from '../openvidu-instance/openvidu-instance.component';
|
import { SessionConf } from '../openvidu-instance/openvidu-instance.component';
|
||||||
|
|
||||||
|
var stringify = require('json-stringify-safe');
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-test-sessions',
|
selector: 'app-test-sessions',
|
||||||
templateUrl: './test-sessions.component.html',
|
templateUrl: './test-sessions.component.html',
|
||||||
|
@ -101,25 +103,12 @@ export class TestSessionsComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
stringifyEventNoCircularDependencies(event: Event): string {
|
stringifyEventNoCircularDependencies(event: Event): string {
|
||||||
const cache = [];
|
return stringify(event, (key, value) => {
|
||||||
return JSON.stringify(event, function (key, value) {
|
// Remove unnecessary properties
|
||||||
if (key !== 'ee' && key !== 'openvidu') {
|
if (key == 'ee' || key == 'openvidu' || key == 'userHandlerArrowHandler' || key == 'handlers') {
|
||||||
if (typeof value === 'object' && value !== null) {
|
return
|
||||||
if (cache.indexOf(value) !== -1) {
|
|
||||||
// Duplicate reference found
|
|
||||||
try {
|
|
||||||
// If this value does not reference a parent
|
|
||||||
return JSON.parse(JSON.stringify(value));
|
|
||||||
} catch (error) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Store value in our collection
|
|
||||||
cache.push(value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue