Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Codable Option to make Codable Structs with forced up-wrapped properties #101

Merged
merged 2 commits into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion JSONExport/HeaderFileRepresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class HeaderFileRepresenter : FileRepresenter{
}

fileContent += ". All rights reserved.\n//\n\n"
fileContent += "//\tModel file Generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport\n\n"
//fileContent += "//\tModel file Generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport\n\n"
}

}
Expand Down
105 changes: 105 additions & 0 deletions JSONExport/Swift-Codable-Unwrapped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"modelStart": "{\n",
"importForEachCustomType": "",
"reservedKeywords": [
"abstract",
"assert",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"default",
"do",
"double",
"else",
"enum",
"extends",
"false",
"final",
"finally",
"float",
"for",
"goto",
"if",
"implements",
"import",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"strictfp",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"true",
"try",
"void",
"volatile",
"while",
"class",
"description"
],
"booleanGetter": "",
"briefDescription": "Defines how your JSON objects can be mapped to Swift structures using the built-in NSJSONSerialization class",
"utilityMethods": [
],
"dataTypes": {
"stringType": "String",
"boolType": "Bool",
"floatType": "Float",
"doubleType": "Double",
"characterType": "Character",
"longType": "Double",
"intType": "Int"
},
"wordsToRemoveToGetArrayElementsType": [
"[",
"]"
],
"constructors": [
{
"fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
"bodyStart": "{\n",
"body": "",
"bodyEnd": "\t}\n",
"fetchBasicTypePropertyFromMap": "\t\tcase <!VarName!> = \"<!JsonKeyName!>\"\n",
"signature": "\tenum CodingKeys: String, CodingKey ",
"fetchArrayOfCustomTypePropertyFromMap": "\t\tcase <!VarName!> = \"<!JsonKeyName!>\"\n",
"comment": "",
"fetchCustomTypePropertyFromMap": "\t\tcase <!VarName!>\n"
}
],
"modelDefinition": "\nstruct <!ModelName!> : Codable ",
"genericType": "AnyObject",
"getter": "",
"setter": "",
"fileExtension": "swift",
"arrayType": "[<!ElementType!>]",
"basicTypesWithSpecialFetchingNeeds": [
],
"displayLangName": "Swift - Struct - Codable - Unwrapped",
"instanceVarDefinition": "\tlet <!VarName!> : <!VarType!>\n",
"supportsFirstLineStatement": "false",
"modelEnd": "\n}",
"staticImports": "import Foundation",
"langName": "Swift"
}
4 changes: 2 additions & 2 deletions JSONExport/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
saveButton.isEnabled = false
var str = sourceText.string!

if str.characters.count == 0{
if str.count == 0{
runOnUiThread{
//Nothing to do, just clear any generated files
self.files.removeAll(keepingCapacity: false)
Expand All @@ -397,7 +397,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
return;
}
var rootClassName = classNameField.stringValue
if rootClassName.characters.count == 0{
if rootClassName.count == 0{
rootClassName = "RootClass"
}
sourceText.isEditable = false
Expand Down