I am very new to Json files. If I have a json file with multiple json objects, located outside the app asset directory in angular at /var/log, the json objects are like such as following:
{"ID":"12345","Timestamp":"20140101", "Usefulness":"Yes",
"Code":[{"event1":"A","result":"1"},…]}
{"ID":"1A35B","Timestamp":"20140102", "Usefulness":"No",
"Code":[{"event1":"B","result":"1"},…]}
{"ID":"AA356","Timestamp":"20140103", "Usefulness":"No",
"Code":[{"event1":"B","result":"0"},…]}
I want to extract all "Timestamp" and "Usefulness" into a data frames in angular js, this is my code:
import { Component, Input } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
//import json from '../../../../../../../../var/log/suricata/eve.json';
import data from "../../../../../../../../var/log/suricata/eve.json";
import { ClassToggleService, HeaderComponent } from '@coreui/angular';
@Component({
selector: 'app-default-header',
templateUrl: './default-header.component.html',
})
export class DefaultHeaderComponent extends HeaderComponent {
@Input() sidebarId: string = "sidebar";
public newMessages = new Array(4)
public newTasks = new Array(5)
public newNotifications = new Array(5)
constructor(private classToggler: ClassToggleService) {
super();
let products: any = (data as any).default;
const myJSON = JSON.stringify(products);
var res = JSON.parse('[' + products.replace(/}}}{/g, '}}},{') + ']');
console.log(res);
//console.log(data.timestamp);
//console.log(data.stats.uptime);
}
}