All Projects → simonboots → json2codable

simonboots / json2codable

Licence: MIT license
A command line tool to generate a Swift Codable struct from a JSON document

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to json2codable

tex-equation-to-svg
Convert a TeX or LaTeX string to an SVG.
Stars: ✭ 34 (+78.95%)
Mutual labels:  converter, convert
Jsontocodable
A generating tool from Raw JSON to Codable (Swift4) text written in Swift4.
Stars: ✭ 33 (+73.68%)
Mutual labels:  converter, codable
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (+1436.84%)
Mutual labels:  converter, convert
to-json-schema
Converts JS objects to JSON Schema
Stars: ✭ 83 (+336.84%)
Mutual labels:  converter, convert
Wx Voice
Convert audio files between Tencent apps (Weixin / Wechat, QQ) and Silk codec with other general formats such as MP3 and M4A
Stars: ✭ 93 (+389.47%)
Mutual labels:  converter, convert
svg2vector
Online batch converter of SVG images to Android vector drawable XML resource files
Stars: ✭ 39 (+105.26%)
Mutual labels:  converter, convert
Breakdance
It's time for your markup to get down! HTML to markdown converter. Breakdance is a highly pluggable, flexible and easy to use.
Stars: ✭ 418 (+2100%)
Mutual labels:  converter, convert
Cashify
💸 Lightweight currency conversion library, successor of money.js
Stars: ✭ 329 (+1631.58%)
Mutual labels:  converter, convert
qTsConverter
A simple tool to convert qt translation file (ts) to other format (xlsx / csv) and vice versa
Stars: ✭ 26 (+36.84%)
Mutual labels:  converter, convert
Youtube Channel Name Converter
A Youtube Channel Name to ID Converter
Stars: ✭ 75 (+294.74%)
Mutual labels:  converter, convert
bafi
Universal JSON, BSON, YAML, CSV, XML converter with templates
Stars: ✭ 65 (+242.11%)
Mutual labels:  converter, convert
Gitconverter
Синхронизация хранилища конфигурации "1С:Предприятия" с репозиторием Git и последующим переходом на разработку в 1C:Enterprise Development Tools (1C:EDT) с сохранением истории
Stars: ✭ 149 (+684.21%)
Mutual labels:  converter, convert
Realm-and-Swift-Codable
How to implement Swift 4 Codable with Realm Database
Stars: ✭ 34 (+78.95%)
Mutual labels:  codable, decodable
xbytes
Parse bytes to human readable sizes (4747) → ('4.75 KB') and vice versa.
Stars: ✭ 17 (-10.53%)
Mutual labels:  converter, convert
HttpUtility
HttpUtility is an open source MIT license project which is helpful in making HTTP requests and returns a decoded object from server. Right now this utility only parses JSON.
Stars: ✭ 28 (+47.37%)
Mutual labels:  encodable, decodable
Ssfconv
Sogou input method skin file (.ssf file) converter, supports conversion to fcitx or fcitx5 format.
Stars: ✭ 44 (+131.58%)
Mutual labels:  converter, convert
Cube2sphere
Python script to map 6 cube (cubemap, skybox) faces into an equirectangular (cylindrical projection, skysphere) map.
Stars: ✭ 120 (+531.58%)
Mutual labels:  converter, convert
Gelatin
Transform text files to XML, JSON, or YAML
Stars: ✭ 150 (+689.47%)
Mutual labels:  converter, convert
bbcode
A BBCode parser and converter written in PHP.
Stars: ✭ 32 (+68.42%)
Mutual labels:  converter
convert
The smallest & fastest library for really easy, totally type-safe unit conversions in TypeScript & JavaScript.
Stars: ✭ 47 (+147.37%)
Mutual labels:  convert

JSON2Codable

JSON2Codable is a simple command-line tool that reads a JSON document from stdin and prints out a new Codable-conforming Swift struct that matches the structure of the JSON document.

Example

$ cat colors.json
{
  "colors": [
    {
      "color": "red",
      "category": "hue",
      "type": "primary",
      "code": {
        "rgba": [255,0,0,1],
        "hex": "#FF0"
      }
    },
    {
      "color": "blue",
      "category": "hue",
      "type": "primary",
      "code": {
        "rgba": [0,0,255,1],
        "hex": "#00F"
      }
    }
  ]
}

$ cat colors.json | json2codable
struct NewType: Codable {
    let colors: [Color]
    struct Color: Codable {
        let category: String
        let code: Code
        struct Code: Codable {
            let hex: String
            let rgba: [Int]
        }
        let color: String
        let type: String
    }
}

Known issues

  • Heterogeneous types in arrays are currently not supported (e.g [123, "string"]) unless the types can be "merged", for example Int can be promoted to Double and any type can become an Optional if a null is present in the array.
  • If the root type of the JSON document is an array, it is unwrapped until a dictionary is found. That dictionary forms the new root type of the final Swift struct. JSON documents with an array root type are expected to be decoded to a Swift type wrapped in an array (e.g. JSONDecoder().decode([SomeType].self, from: jsonData))
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].