CuteBaby: JSON Model Generator for Swift

NIX
NIX
Jul 31, 2017 · 3 min read

CuteBaby can generate Swift models (struct or class) from a JSON string.

Image for post
Image for post
CuteBaby: JSON Model Generator for Swift

It has some nice features to customize the models that it generated.

  1. It can infer property’s type from JSON such as String, Int, Double, URL and Date.
  2. It can handle nested JSON, it will generate nested models.
  3. It supports Codable from Swift 4.
  4. You can specify property’s name with Property Map, array’s object name with Array Object Map, property’s type with Property Type Map, or enum’s definition with Enum Properties.
  5. It can also handle array root JSON, it will automatically merge properties for objects in the array.
  6. It can format JSON with pretty printed.
  7. It can load JSON from a URL.
  8. You can Drag & Drop text files to create new items.

For JSON:

It’ll generate Swift code (with ):

Note that there use Property Map to change the property name (Automatically generated will be ).

Swift code without :

You may need a extension if you do not use :

For JSON:

It’ll generate Swift code (with ):

Note that there use Array Object Map to change the object name (Automatically generated will be ).

For JSON:

It’ll generate Swift code (with ):

Note that there use Enum Properties to generate enum Gender for gender property. Also use Array Object Map to change the object name (Automatically generated will be ).


Image for post
Image for post

You can also paste a URL in the top right text view, CuteBaby will try to load JSON from it automatically.


Create models from a JSON string, even a CuteBaby can do it.

Get the CuteBaby on the Mac App Store.

Or SmartBaby on the Mac App Store. It’s smarter.

I wish you like it. 😀💕

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store