All Projects → YutoMizutani → Jsontocodable

YutoMizutani / Jsontocodable

Licence: mit
A generating tool from Raw JSON to Codable (Swift4) text written in Swift4.

Programming Languages

swift
15916 projects
swift4
162 projects

Projects that are alternatives of or similar to Jsontocodable

Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (+666.67%)
Mutual labels:  json, generator
Sqawk
Like Awk but with SQL and table joins
Stars: ✭ 263 (+696.97%)
Mutual labels:  json, converter
json2codable
A command line tool to generate a Swift Codable struct from a JSON document
Stars: ✭ 19 (-42.42%)
Mutual labels:  converter, codable
Dataset Serialize
JSON to DataSet and DataSet to JSON converter for Delphi and Lazarus (FPC)
Stars: ✭ 213 (+545.45%)
Mutual labels:  json, converter
Swiftai
SwiftAI, write Swift code smart. SwiftAI can generate Model class from JSON now. Codable and HandyJSON is supported. More features will be add.
Stars: ✭ 470 (+1324.24%)
Mutual labels:  json, codable
Retrofit Logansquare
A Converter implementation using LoganSquare JSON serialization for Retrofit 2.
Stars: ✭ 224 (+578.79%)
Mutual labels:  json, converter
goverter
Generate type-safe Go converters by simply defining an interface
Stars: ✭ 100 (+203.03%)
Mutual labels:  converter, generator
Cleanjson
Swift JSON decoder for Codable
Stars: ✭ 178 (+439.39%)
Mutual labels:  json, codable
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (+1175.76%)
Mutual labels:  json, converter
Jet
CLI to transform between JSON, EDN and Transit, powered with a minimal query language.
Stars: ✭ 331 (+903.03%)
Mutual labels:  json, converter
Jsonsubtypes
Discriminated Json Subtypes Converter implementation for .NET
Stars: ✭ 201 (+509.09%)
Mutual labels:  json, converter
Sqlitebiter
A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
Stars: ✭ 601 (+1721.21%)
Mutual labels:  json, converter
Swagger Toolbox
💡 Swagger schema model (in yaml, json) generator from json data
Stars: ✭ 194 (+487.88%)
Mutual labels:  json, converter
Keyedcodable
Easy nested key mappings for swift Codable
Stars: ✭ 248 (+651.52%)
Mutual labels:  json, codable
Sdk
Library for using Grafana' structures in Go programs and client for Grafana REST API.
Stars: ✭ 193 (+484.85%)
Mutual labels:  json, generator
FigmaConvertXib
FigmaConvertXib is a tool for exporting design elements from figma.com and generating files to a projects iOS .xib / Android .xml
Stars: ✭ 111 (+236.36%)
Mutual labels:  converter, generator
Goxml2json
XML to JSON converter written in Go (no schema, no structs)
Stars: ✭ 170 (+415.15%)
Mutual labels:  json, converter
Node Js2xmlparser
Popular Node.js module for parsing JavaScript objects into XML
Stars: ✭ 171 (+418.18%)
Mutual labels:  json, converter
Mimesis
Mimesis is a high-performance fake data generator for Python, which provides data for a variety of purposes in a variety of languages.
Stars: ✭ 3,439 (+10321.21%)
Mutual labels:  json, generator
Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+1439.39%)
Mutual labels:  json, generator

JSONtoCodable

Build Status CocoaPods MIT License CocoaPods Carthage compatible codecov

JSONtoCodable is a generating tool from Raw JSON to Codable (Swift4) text written in Swift4.

Qiita: JSONからCodable化されたstructを自動生成するツールを作った話 - Qiita

demo_macos.png

TL;DR

From JSON,

{
    "user": {
        "Name": "Yuto Mizutani"
    },
    "lib": {
        "lib-name": "JSONtoCodable",
        "year": 2018,
        "version": "1.0.2",
        "released": "2018-09-22"
    },
    "text": "Hello, world!!"
}

to Codable.

public struct Result: Codable {
    public let user: User
    public let lib: Lib
    public let text: String

    public struct User: Codable {
        public let name: String

        private enum CodingKeys: String, CodingKey {
            case name = "Name"
        }
    }

    public struct Lib: Codable {
        public let libName: String
        public let year: Int
        public let version: String
        public let released: String

        private enum CodingKeys: String, CodingKey {
            case libName = "lib-name"
            case year
            case version
            case released
        }
    }
}

JaCo (macOS App)

demo_macos.png

jc (CLI App)

Installation

$ brew tap YutoMizutani/jc
$ brew install jc

Usage example

$ curl https://httpbin.org/get | jc

or generate .swift file,

$ curl https://httpbin.org/get | jc > Result.swift

Help command

$ jc -h

Screen shot

demo_cli.png

Support formats

  • Type
    • String
    • Bool
    • Int
    • Double
    • struct(s)
    • Optional
  • Array
    • Start array
    • Muptiple array
    • Arrayed objects
    • Optional array
  • Number of nested array and objects
    • Infinity
  • Number of spaces in entered JSON
    • 0 to infinity

Translations

JSON Value Swift Type
"text" String
true Bool
-10 Int
1.0 Double
null <Foo>?
(the others) Any

Usage

import JSONtoCodable

let json: String = """
{
    "Hello": "Hello, world!!"
}
"""

let jsonToCodable = JSONtoCodable()
let codable = try? jsonToCodable.generate(json)

print(codable)
/*
struct Result: Codable {
    let hello: String

    private enum CodingKeys: String, CodingKey {
        case hello = "Hello"
    }
}
*/

Config

let config = Config()
config.name = "Result" // struct Result: Codable {}
config.accessModifier = AccessModifier.public // public struct
config.caseType = (variable: CaseType.camel, struct: CaseType.pascal)
config.lineType = LineType.lineFeed
config.indentType = IndentType.space(4)

See more: Config.swift

Installation

Cocoapods

Add this to your Podfile:

pod 'JSONtoCodable'

and

$ pod install

Carthage

Add this to your Cartfile:

github "YutoMizutani/JSONtoCodable"

and

$ carthage update

License

JSONtoCodable is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].