Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
How to extract multiple JSON objects from one json file located outside the app directory in angular?

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);
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda