Giter Club home page Giter Club logo

ugc2json-converter's Introduction

UGC to JSON Converter

Create JSON files without needing to use explicit JSON structure

UGC (User-Generated Content) files is a more practical way to create JSON files without needing to use explicit JSON structure. It can be used on any projetct that you may have to create JSON files by hand without the need to place brackers and quotation marks to indicates value keys.

๐Ÿ’  Table of Contents

โœ… How to use

  • Create a *.ugc file with the UGC file structure (see below).
  • Place the ugc2json.py file on the same directory of your .ugc files and execute it.
  • JSON files will be generated.

โš™๏ธ Declare Class Types

A few features of your generated JSON file can be manipulated by placing #declare classes at the very beginning of your UGC file. There's all possible declare options:

Root Type

The generated JSON file can be both a dict or a list. By default, the script will generate the JSON root as a dict. But if you want the root as a list, you just need to place the following declarative class at the first line of your UGC file:

#declare list
[...]

By declaring the root type as a list, the rules to declare any value to a list must be followed (no key names, only values).

Minify

The generated JSON file will be generated minified by placing:

#declare minify
[...]

NOTE : All these declaring classes can be used together but you have to declare them individually.

#declare list
#declare minify
[...]

โญ•๏ธ Script Variables

Certain features can be enabled/disabled changing variables on the script, here's all variables:

subdirs : Scan Subdirectories ON/OFF

By default, the script scans for UGC files on the root subdirectories, you can restrict the scanning only for the root folder changing the subdirs variable inside the Python script to False.

๐Ÿ“„ Value Types

Strings

Strings are declared with quotation marks as default, but this rule can be broken if it is a string with a single word (lovely called a "code string").

code_string_example ugc2json_converter
normal_string "This is a normal string."

Numbers

Int and float are declared just by putting the number after the key name.

int_example 1
float_example 1.2

Booleans

Booleans are declared putting TRUE or FALSE (All uppercase) after the key name.

boolean_example TRUE

Null Values

Null values are declared putting NONE after the key name.

null_value_example NONE

Dicts

Dicts are declared by placing #set and the key name right after. To close it, just place an #endset alone.

#set dict_example
    desc "This "desc" string will be placed inside "dict_example"."
#endset

Inside a list, dicts are declared just by placing #set.

#list list_with_dicts
    #set
        will_be_index 0
    #endset
    #set
        will_be_index 1
    #endset
#list

Lists

Like dicts, lists are declared by placing #list and the key name right after. To close it, just place an #endlist alone. By being a list, values are declared alone (without key names)

#list list_example                                  | List opened
    "This string will be appended at index 0."      | String
    "This, at index 1."                             | String
    "And this at index 2."                          | String
    3                                               | Int
    index_4                                         | String (Code String)
    TRUE                                            | Boolean
#endlist                                            | List closed

Inside another list, list are declared just by placing #list.

#list list_with_lists
    #list
        "This string will be at index 0 inside a list, that is the index 0 inside the "list_with_lists" list."
    #endlist
    "This string will be at index 1 inside the "list_with_lists" list."
#list

โž• Comments

By now, UGC to JSON Converter only supports Inline Comments only. To place an inline comment, just use ## followed by a space and your comment.

## This is a comment and will be ignored.

ugc2json-converter's People

Contributors

ruggeryiury avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.