<commit_before>import Jay
import Foundation

func tryParsing() {

    let data = Array("{\t\"hello\" : \"wor🇨🇿ld\", \n\t \"val\": 1234, \"many\": [\n-12.32, null, \"yo\"\r], \"emptyDict\": {}, \"dict\": {\"arr\":[]}, \"name\": true}".utf8)
    let exp: [String: Any] = [
        "hello": "wor🇨🇿ld",
        "val": 1234,
        "many": [
            -12.32,
            NSNull(),
            "yo"
        ] as [Any],
        "emptyDict": [String:Any](),
        "dict": [
            "arr": [Any]()
        ],
        "name": true
    ]
    let expStr = "\(exp)"

    let json = try! Jay().jsonFromData(data)
    let retStr = "\(json)"

    assert(expStr == retStr)
    print("Parsing works")
}

func tryFormatting() {

    let origStr = "{\"dict\":{\"arr\":[]},\"emptyDict\":{},\"hello\":\"wor🇨🇿ld\",\"many\":[-12.32,null,\"yo\"],\"name\":true,\"val\":1234}"
    let obj: [String: Any] = [
        "hello": "wor🇨🇿ld",
        "val": 1234,
        "many": [
            -12.32,
            NSNull(),
            "yo"
        ] as [Any],
        "emptyDict": [String:Any](),
        "dict": [
            "arr": [Int]()
        ],
        "name": true
    ]

    let dataOut = try! Jay().dataFromJson(obj)
    let retStr = try! dataOut.string()

    assert(origStr == retStr)
    print("Formatting works")<commit_msg>fixes for linux<commit_after>import Jay
import Foundation

func tryParsing() {

    let data = Array("{\t\"hello\" : \"wor🇨🇿ld\", \n\t \"val\": 1234, \"many\": [\n-12.32, \"yo\"\r], \"emptyDict\": {}, \"dict\": {\"arr\":[]}, \"name\": true}".utf8)
    let exp: [String: Any] = [
        "hello": "wor🇨🇿ld",
        "val": 1234,
        "many": [
            -12.32,
            // null, add NSNull back once we can reliably compare object hierarchies
            "yo"
        ] as [Any],
        "emptyDict": [String:Any](),
        "dict": [
            "arr": [Any]()
        ],
        "name": true
    ]
    let expStr = "\(exp)"

    let json = try! Jay().jsonFromData(data)
    let retStr = "\(json)"

    assert(expStr == retStr, "Mismatch: Expected:\n\(expStr)\nReturned:\n\(retStr)")
    print("Parsing works")
}

func tryFormatting() {

    let origStr = "{\"dict\":{\"arr\":[]},\"emptyDict\":{},\"hello\":\"wor🇨🇿ld\",\"many\":[-12.32,null,\"yo\"],\"name\":true,\"val\":1234}"
    let obj: [String: Any] = [
        "hello": "wor🇨🇿ld",
        "val": 1234,
        "many": [
            -12.32,
            NSNull(),
            "yo"
        ] as [Any],
        "emptyDict": [String: Any](),
        "dict": [
            "arr": [Int]()
        ] as [String: Any],
        "name": true
    ]

    let dataOut = try! Jay().dataFromJson(obj)
    let retStr = try! dataOut.string()

    assert(origStr == retStr, "Mismatch: Expected:\n\(expStr)\nReturned:\n\(retStr)")
    print("Formatting works")
{'fraction_non_alphanumeric': 0.23750443105281815, 'fraction_numerical': 0.02339595887982985, 'mean_word_length': 1.906282183316169, 'pattern_counts': {'":': 54, '<': 3, '<?xml version=': 0, '>': 3, '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': '5911054', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1011, 'n_words': 208}