npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@2bttns/formatter

v1.2.4

Published

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

Downloads

35

Readme

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.