jweinst1
10/25/2016 - 7:42 PM

new json parser

new json parser

//gets a JSON string from a url via a get request
func getJSON(address:String) -> String? {
    if let url = URL(string: address) {
        do {
            let contents = try String(contentsOf: url)
            return contents
        } catch {
            return nil
        }
    } else {
        return nil
    }
}

//main JSON enum wrapper for Avocado parser
enum JSON {
    case number(Int)
    case string(String)
    case boolean(Bool)
    indirect case array([JSON])
    indirect case object([String:JSON])
    case null
}

enum Jmode {
    case Okey
    case col
    case Oval
    case com
    case number
    case string
    case bool
    case null
    case Aval
}

let intset:Set<Character> = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]





let a = "hello world"
let b = a.startIndex
let c = a.index(after: b)
let d = a.substring(to: c)