// // ExtendedJSON.swift // MongoView // // Created by Shadowfacts on 4/4/20. // Copyright © 2020 Shadowfacts. All rights reserved. // import Foundation import JavaScriptCore struct ExtendedJSON { private init() {} private static let context: JSContext = { let context = JSContext()! let objectId: @convention(block) (String) -> [String: String] = { (id) in return ["$oid": id] } context.setObject(objectId, forKeyedSubscript: "ObjectId" as NSString) return context }() static func normalize(_ string: String) -> String? { return context.evaluateScript("JSON.stringify(\(string))")?.toString() } }