From 3cb2c6d51430ef8984f1d8b4a4823ac29a9a1ec1 Mon Sep 17 00:00:00 2001 From: std-s <278779615@qq.com> Date: Tue, 10 May 2022 15:02:18 +0800 Subject: [PATCH] [Fix] object is NSNull. --- ios/Classes/JsonUtil.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ios/Classes/JsonUtil.swift b/ios/Classes/JsonUtil.swift index 5c005d6..fe6d684 100644 --- a/ios/Classes/JsonUtil.swift +++ b/ios/Classes/JsonUtil.swift @@ -3,9 +3,15 @@ import Foundation public class JsonUtil { public static func toString(object: AnyObject?)->String { + + if object is NSNull { + return "" + } + if object == nil { return "" } + if object is String{ let s = object as! String let b = s.replacingOccurrences(of: "\"", with: "\\\"")