<commit_before>//
//  String+Extension.swift
//  JWTDesktopSwift
//
//  Created by <NAME> on 30.10.2017.
//  Copyright © 2017 JWTIO. All rights reserved.
//

import Foundation
extension String {
    static func json(_ object: Any?) -> String {
        guard let jsonObject = object else {
            return ""
        }
        
        if !JSONSerialization.isValidJSONObject(jsonObject) {
            print("object is not valid JSONObject: \(jsonObject)")
            return ""
        }
        
        guard let data = try? JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted) else {
            return ""
        }
        
        guard let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else {
            return ""
        }
        
        return string as String
    }
}<commit_msg>Gets rid of not needed NSString<commit_after>//
//  String+Extension.swift
//  JWTDesktopSwift
//
//  Created by <NAME> on 30.10.2017.
//  Copyright © 2017 JWTIO. All rights reserved.
//

import Foundation
extension String {
    static func json(_ object: Any?) -> String {
        guard let jsonObject = object else {
            return ""
        }
        
        if !JSONSerialization.isValidJSONObject(jsonObject) {
            print("object is not valid JSONObject: \(jsonObject)")
            return ""
        }
        
        guard let data = try? JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted) else {
            return ""
        }

        guard let string = String(data: data, encoding: .utf8) else {
            return ""
        }
        return string
    }
}
{'fraction_non_alphanumeric': 0.10066707095209218, 'fraction_numerical': 0.015767131594906003, 'mean_word_length': 1.849740932642487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7658895', 'n_tokens_mistral': 470, 'n_tokens_neox': 441, 'n_words': 129}