This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AutolayoutHelper.swift | |
// | |
// Created by Pawan on 30/07/19. | |
// Copyright © 2019 Pawan. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary { | |
var json: String { | |
let invalidJson = "Error: Invalid JSON" | |
do { | |
let jsonData = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) | |
return String(bytes: jsonData, encoding: String.Encoding.utf8) ?? invalidJson | |
} catch { | |
return invalidJson | |
} | |
} |