# Goal

To enable Business Intelligence team visualising legacy database table dependencies on designing a migration process

# Scope

As this an exploratory study, R was chosen to read, process and transform a JSON file with database table dependencies into a file with a graph format.

# Procedure

## 1.- Read the JSON file

To read the JSON file, I used the rjon library to read from a text file having the data in a JSON structure.

library("rjson")
json_file <- "jsonTV.txt"
json_data <- fromJSON(file=json_file)

## 2.- Transform JSON structure into a data frame

For transforming JSON structure into a data frame, I developed a function populateData.

populateDFData <- function(json_data,df_data) {
rowIndex <- 0
for (i in 1:length(json_data)) {

lengthImport <- length(json_data[[i]]$imports) if (lengthImport>0) { for (j in 1:lengthImport) { rowIndex <- rowIndex+1 df_data[rowIndex,"name"]<-json_data[[i]]$name
df_data[rowIndex,"size"]<-json_data[[i]]$size import <- json_data[[i]]$imports
df_data[rowIndex,"imports"]<-import[[j]]
} } else{
rowIndex <- rowIndex + 1
df_data[rowIndex,"name"]<-json_data[[i]]$name df_data[rowIndex,"size"]<-json_data[[i]]$size
df_data[rowIndex,"imports"]<-"<NA>"
}

}
}

I declare a data frame whose number of rows were calculated using a function calculateLength, that defines a record for each occurrence of the tuple (name, import), where name is the table and import its dependencies.

calculateLength <- function(jsonObject) {
dfLength <- 0
for (i in 1:length(jsonObject)) {

One Comment