All Projects → jiro4989 → nimjson

jiro4989 / nimjson

Licence: MIT License
nimjson generates nim object definitions from json documents.

Programming Languages

nim
578 projects

Projects that are alternatives of or similar to nimjson

logger-node
A nodejs logger client for LogDNA
Stars: ✭ 27 (-27.03%)
Mutual labels:  lib
cli
Aplus Framework CLI Library
Stars: ✭ 104 (+181.08%)
Mutual labels:  command
clui
A command system with extra steps
Stars: ✭ 18 (-51.35%)
Mutual labels:  command
NodeJS-Red-Team-Cheat-Sheet
NodeJS Red-Team Cheat Sheet
Stars: ✭ 121 (+227.03%)
Mutual labels:  command
database
Simple and easy go database micro framework
Stars: ✭ 12 (-67.57%)
Mutual labels:  command
sqrs
🚌SQRS is a JavaScript library for implementing CQRS pattern.
Stars: ✭ 23 (-37.84%)
Mutual labels:  command
colortest
Quickly show all your terminal colors
Stars: ✭ 66 (+78.38%)
Mutual labels:  command
Assembly-Lib
A 16-bits x86 DOS Assembly library that provides many useful functions for developing programs. It has both VGA grapics functions as well as general purpose utilities. The main purpose of this library was to be able to implement simple DOS games (in Assembly) using VGA (320x200, 256 colors) display.
Stars: ✭ 36 (-2.7%)
Mutual labels:  lib
ucollage
An extensible command line image viewer inspired by vim
Stars: ✭ 161 (+335.14%)
Mutual labels:  command
linux-command
➥ Linux 命令查询工具跨平台桌面版
Stars: ✭ 133 (+259.46%)
Mutual labels:  command
TinyMAT
C/C++ library to handle writing simple Matlab(r) MAT file
Stars: ✭ 22 (-40.54%)
Mutual labels:  lib
client-js
JS client for polygon.io api
Stars: ✭ 81 (+118.92%)
Mutual labels:  lib
crack-pro
NEW FACEBOOK COINING TOOL
Stars: ✭ 77 (+108.11%)
Mutual labels:  command
TinyTIFF
lightweight TIFF reader/writer library (C/C++)
Stars: ✭ 91 (+145.95%)
Mutual labels:  lib
caddy-exec
Caddy v2 module for running one-off commands
Stars: ✭ 48 (+29.73%)
Mutual labels:  command
reload
Simple managed reload mechanism for Go
Stars: ✭ 18 (-51.35%)
Mutual labels:  lib
vscode-terminals
An extension for setting-up multiple terminals at once, or just running some commands.
Stars: ✭ 83 (+124.32%)
Mutual labels:  command
dotty dict
Dictionary wrapper for quick access to deeply nested keys.
Stars: ✭ 67 (+81.08%)
Mutual labels:  lib
discord.ts
🤖 Create your discord bot by using TypeScript and decorators!
Stars: ✭ 315 (+751.35%)
Mutual labels:  command
command help
ℹ️ Extract help text from builtin commands and man pages
Stars: ✭ 54 (+45.95%)
Mutual labels:  command

nimjson

CI Status Install Status Doc Status

nimjson generates nim object definitions from json documents. This was inspired by gojson.

Development

  • Nim (stable version)

Usage examples

nimjson writes NilType type if a value or a first value of an array is null. Please fix NilType type yourself.

Large JSON example

% curl -s https://api.github.com/repos/jiro4989/nimjson | nimjson -O:Repository
type
  NilType = ref object
  Repository = ref object
    id: int64
    node_id: string
    name: string
    full_name: string
    private: bool
    owner: Owner
    html_url: string
    description: string
    fork: bool
    url: string
    forks_url: string
    keys_url: string
    collaborators_url: string
    teams_url: string
    hooks_url: string
    issue_events_url: string
    events_url: string
    assignees_url: string
    branches_url: string
    tags_url: string
    blobs_url: string
    git_tags_url: string
    git_refs_url: string
    trees_url: string
    statuses_url: string
    languages_url: string
    stargazers_url: string
    contributors_url: string
    subscribers_url: string
    subscription_url: string
    commits_url: string
    git_commits_url: string
    comments_url: string
    issue_comment_url: string
    contents_url: string
    compare_url: string
    merges_url: string
    archive_url: string
    downloads_url: string
    issues_url: string
    pulls_url: string
    milestones_url: string
    notifications_url: string
    labels_url: string
    releases_url: string
    deployments_url: string
    created_at: string
    updated_at: string
    pushed_at: string
    git_url: string
    ssh_url: string
    clone_url: string
    svn_url: string
    homepage: string
    size: int64
    stargazers_count: int64
    watchers_count: int64
    language: string
    has_issues: bool
    has_projects: bool
    has_downloads: bool
    has_wiki: bool
    has_pages: bool
    forks_count: int64
    mirror_url: NilType
    archived: bool
    disabled: bool
    open_issues_count: int64
    license: License
    allow_forking: bool
    is_template: bool
    topics: seq[string]
    visibility: string
    forks: int64
    open_issues: int64
    watchers: int64
    default_branch: string
    temp_clone_token: NilType
    network_count: int64
    subscribers_count: int64
  Owner = ref object
    login: string
    id: int64
    node_id: string
    avatar_url: string
    gravatar_id: string
    url: string
    html_url: string
    followers_url: string
    following_url: string
    gists_url: string
    starred_url: string
    subscriptions_url: string
    organizations_url: string
    repos_url: string
    events_url: string
    received_events_url: string
    `type`: string
    site_admin: bool
  License = ref object
    key: string
    name: string
    spdx_id: string
    url: string
    node_id: string

Simple JSON example

% nimjson examples/primitive.json
type
  NilType = ref object
  Object = ref object
    stringField: string
    intField: int64
    floatField: float64
    boolField: bool
    nullField: NilType

% nimjson examples/array.json
type
  NilType = ref object
  Object = ref object
    strArray: seq[string]
    intArray: seq[int64]
    floatArray: seq[float64]
    boolArray: seq[bool]
    nullArray: seq[NilType]
    emptyArray: seq[NilType]

% nimjson examples/object.json
type
  NilType = ref object
  Object = ref object
    point: Point
    length: int64
    responseCode: string
    debugFlag: bool
    rectangles: seq[Rectangles]
  Point = ref object
    x: float64
    y: float64
  Rectangles = ref object
    width: int64
    height: int64

API usage

import std/json

import nimjson

echo """{"keyStr":"str", "keyInt":1}""".parseJson().toTypeString()

# Output:
# type
#   NilType = ref object
#   Object = ref object
#     keyStr: string
#     keyInt: int64

echo "examples/primitive.json".parseFile().toTypeString("testObject")

# Output:
# type
#   NilType = ref object
#   TestObject = ref object
#     stringField: string
#     intField: int64
#     floatField: float64
#     boolField: bool
#     nullField: NilType

Installation

Nim users

nimble install nimjson

Linux users (Debian base distros)

wget https://github.com/jiro4989/nimjson/releases/download/v2.0.0/nimjson_2.0.0_amd64.deb
sudo dpkg -i ./nimjson*.deb

Linux users (RHEL compatible distros)

yum install https://github.com/jiro4989/nimjson/releases/download/v2.0.0/nimjson-2.0.0-1.el7.x86_64.rpm

Help

nimjson -h

nimjson generates nim object definitions from json documents.

Usage:
    nimjson [options] [files...]
    nimjson (-h | --help)
    nimjson (-v | --version)

Options:
    -h, --help                       Print this help
    -v, --version                    Print version
    -X, --debug                      Debug on
    -o, --out-file:FILE_PATH         Write file path
    -O, --object-name:OBJECT_NAME    Set object type name
    -p, --public-field               Public fields
    -q, --quote-field                Quotes all fields

License

MIT

Document

Web application of nimjson

I created simple nimjson on web application.

https://jiro4989.github.io/nimjson

Javascript library of nimjson of the application is generated by this module (nimble js).

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].