blob: 8d5eff1027dd5dc33493060fc82fc117583aac66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class UtilsService {
constructor() { }
isValidJSON(json) {
try {
var checkJSON = JSON.parse(JSON.stringify(json));
if (checkJSON && typeof checkJSON === 'object' && checkJSON !== null) {
// this.$log.debug('UtilsService::isValidJSON: JSON is valid!');
return true;
}
} catch (err) {
// this.$log.debug('UtilsService::isValidJSON: json passed is not valid: ' + JSON.stringify(err));
}
return false;
}
}
|