How to use JSON2HTML in Swift?

let jsfile1 = try!String(contentsOfFile: Bundle.main.path(forResource: “json2html”, ofType: “js”)!)

func loadJS()
{
var getData={}
var context = JSContext()
var valSwiftyJson:JSON = [:]
var test = context?.evaluateScript(jsfile1)

let testFunction = test?.objectForKeyedSubscript("json2html")

let urlString = //Have removed the URL string due to restrictions
Alamofire.request(urlString,encoding:JSONEncoding.default).responseJSON
    { response in
        if let alamoJson = response.result.value
        {
            let swiftyJson = JSON(data:response.data!)
            valSwiftyJson = swiftyJson["FormInfo"]["Form"]
            print(valSwiftyJson)
        }

}
let result = testFunction?.call(withArguments: [getData,valSwiftyJson])
webView.loadHTMLString((result?.toString())!, baseURL: nil)

}

I’m getting output as undefined. I could further proceed with the project only if I integrate JSON2HTML as the server response(JSON) is formatted in such a way.
I don’t know if I had made any mistake in my code. Please help, thanks in advance!

@javid94. When you say your output is undefined, at what point is this happening? Are you able to connect to your endpoint, and print the JSON output to the console? My suggestion is to first identify where the error is occurring. If the problem is with the JSON output, then at least you know the problem my be on the server side, or could be the way you are trying to parse the JSON. Just a thought.

I hope this helps!

All the best!