All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.joern.csharpsrc2cpg.parser.DotNetJsonParser.scala Maven / Gradle / Ivy

There is a newer version: 4.0.131
Show newest version
package io.joern.csharpsrc2cpg.parser

import io.joern.x2cpg.astgen.ParserResult
import io.shiftleft.utils.IOUtils
import org.slf4j.LoggerFactory
import ujson.Value.Value

import java.nio.file.{Path, Paths}
import scala.util.Try
object DotNetJsonParser {

  def readFile(file: Path): ParserResult = {
    val jsonContent       = IOUtils.readLinesInFile(file).mkString
    val json              = ujson.read(jsonContent)
    val fullFilePath      = json(ParserKeys.FileName).str
    val filePath          = Paths.get(fullFilePath)
    val sourceFileContent = IOUtils.readEntireFile(filePath)
    ParserResult(filePath.getFileName.toString, fullFilePath, json, sourceFileContent)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy