1.2.4 ā€¢ Published 10 months ago

@2bttns/formatter v1.2.4

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Game Object Formatter

Convert JSON data into a format readable by the 2bttns Console.

Usage

npx @2bttns/formatter
āœ” What do you want to do? Ā· Format data for 2bttns Console
āœ” šŸ“ Enter the path of the input JSON file:  Ā· unformatted-data/genres.json
āœ” šŸ” Select the path in JSON where the data to be converted is located:  Ā· genres
āœ” ā­ļø Which key in your JSON corresponds to "id" with value type "string"?
 šŸ‘‰ Enter "none" if none exists. Ā· id
āœ” ā­ļø Which key in your JSON corresponds to "name" with value type "string"?
 šŸ‘‰ Enter "none" if none exists. Ā· name
āœ” ā­ļø Which key in your JSON corresponds to "description" with value type "string"?
 šŸ‘‰ Enter "none" if none exists. Ā· none
āœ” ā­ļø Which key in your JSON corresponds to "tagIds" with value type "object"?
 šŸ‘‰ Enter "none" if none exists. Ā· none
āœ” šŸ“ Enter the path where you want to save the output JSON file (e.g., /your/path/name/):  Ā· /Users/admin/Desktop/2bttns Company
āœ… Output JSON file saved successfully! āœ…

Format data for 2bttns Console will guide you through mapping your JSON and generating a ready to upload file.

Get ready-to-upload json data will download already formatted Game Objects available in the formatter.

# Ready to upload json data
? Select the JSON file you want to output from the /formatted-data folder: ā€¦ 
āÆ ready-car-considerations.json
  ready-chords.json
  ready-indoorActivities.json
  ready-outdoorActivities.json

Table of Contents

  1. Data Model
  2. Usage
  3. Example
  4. Upload to Console
  5. License

Warnin

The Tags section at the bottom of the output JSON is currently set to have empty strings for id, name, and description fields. As a result, a new Tag object will be generated in the Console.

Game Objects Model

The script converts any size JSON into the data model below.

Your JSON must contain a name equivalent field. These values are loaded as choices within your Game buttons.

Fields not represented in the Game Objects model are ignored. See Example for more information.

const outputShape: OutputShape = {
  gameObjects: [
    {
      id: '',
      name: '',
      description: '',
      tagIds: []
    }
  ],
  tags: [
    {
      id: '',
      name: '',
      description: ''
    }
  ]
};

Interface Type

interface GameObject {
  id: string;
  name: string;
  description: string;
  tagIds: string[];
  [key: string]: any;
}

Example

Here's an example of the input JSON:

{
    "chords": [
      {
        "name": "C Major",
        "notes": ["C", "E", "G"]
      },
      {
        "name": "C Minor",
        "notes": ["C", "Eb", "G"]
      },
      {
        "name": "D Major",
        "notes": ["D", "F#", "A"]
      },
      ...
    ]
}

And here's the resulting output JSON:

{
  "gameObjects": [
    {
      "id": "cljgvm1w00000679s2l9a5zql",
      "name": "C Major",
      "description": "",
      "tagIds": []
    },
    {
      "id": "cljgvm1w10001679sdppzbk1p",
      "name": "C Minor",
      "description": "",
      "tagIds": []
    },
    {
      "id": "cljgvm1w10002679sda2j6i75",
      "name": "D Major",
      "description": "",
      "tagIds": []
    },
    ...
  ],
  "tags": [
    {
      "id": "",
      "name": "",
      "description": ""
    }
  ]
}

Upload to Console

Now your new json is ready to be uploaded.

  1. Locate your converted data inside output.
  2. Open your Console
  3. Navigate to Game Objects
  4. Click Actions then Import from JSON
  5. Upload the ready-for-upload.json file and click Confirm.

Your Game Objects are now ready to be Tagged!

License

This project is licensed under the MIT License.

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago