Ahmed-Ali / JSONExport

JSONExport is a desktop application for Mac OS X which enables you to export JSON objects as model classes with their associated constructors, utility methods, setters and getters in your favorite language.
Other
4.79k stars 794 forks source link

Fatal error: Unexpectedly found nil while unwrapping an Optional value #125

Open PlutusCat opened 5 years ago

PlutusCat commented 5 years ago

Xcode 10.1 MacOS 10.14.1

I have some json code,and choose SwiftyJSON-Class , There will be a crash.

{
  "code" : "200",
  "message" : "匹配完成",
  "data" : {
    "stackTrace" : [
      {
        "nativeMethod" : false,
        "fileName" : "NullObject.java",
        "className" : "org.codehaus.groovy.runtime.NullObject",
        "lineNumber" : 60,
        "methodName" : "getProperty"
      },
      {
        "nativeMethod" : false,
        "fileName" : "InvokerHelper.java",
        "className" : "org.codehaus.groovy.runtime.InvokerHelper",
        "lineNumber" : 190,
        "methodName" : "getProperty"
      }
    ],
    "cause" : null,
    "localizedMessage" : "Cannot get property 'minimumAmount' on null object",
    "message" : "Cannot get property 'minimumAmount' on null object",
    "suppressed" : [

    ]
  }
}

On the FileRepresenter.swift In line No. 484, It's a null value.

// if needs cast
let cast = lang.basicTypesWithSpecialFetchingNeedsTypeCast[index]
wangela commented 5 years ago

+1 on this, also running on Xcode 10.1 MacOS 10.14.1

Console also says 2018-12-04 10:48:23.151777-0800 JSONExport[14745:1985495] [default] Unable to load Info.plist exceptions (eGPUOverrides) (lldb)

brianramirez commented 5 years ago

I ran into this same issue with SwiftyJSON just now with my JSON structure. I think that the JSONExport tool is barfing with creating the Constructors for SwiftyJSON when the JSON has empty arrays. As soon as I provided values for my empty arrays, the tool works perfectly.