//
//  Array+Extension.swift
//  galaxy
//
//  Created by davidhuangA on 2023/12/28.
//  Copyright © 2023 www.davidhuang.com. All rights reserved.
//

import Foundation
extension Array {
    /// 数组转json字符串
    func yh_toJSONString() -> String? {
        if (!JSONSerialization.isValidJSONObject(self)) {
            return nil
        }
        
        do {
            let data = try JSONSerialization.data(withJSONObject: self, options: [])
            let json = String(data: data, encoding: String.Encoding.utf8)
            return json
        } catch {
            return nil
        }
    }
}
