Skip to content

Visual Studio extension that adds several JSON-conversion features within the IDE. Generate C# types from JSON. Serialize C# types to JSON (within code editor). Change cases of phrases.

License

Notifications You must be signed in to change notification settings

andeart/JsonButler-IDE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo-v2-64-vs JsonButler-IDE

github-release github-dls

JsonButler-IDE lets you use JsonButler's features inside your Visual Studio environment, along with some additional features.

  • Generate C# types from JSON snippets/files.
  • Serialize C# types to JSON text, from within Visual Studio (project does not need to be running).
  • Easily change cases of phrases (to camelCase, lower_snake_case, PascalCase, and _underscoreCamelCase).
  • More features coming soon!

Generate C# types from JSON snippets/files.

Convert your JSON snippets easily into C# types usable in code.
For example:
json-source
automatically generates:

namespace Andeart.CustomPayloads
{
    public class MyNewPayload
    {
        [JsonProperty ("name")]
        public string Name { get; private set; }

        [JsonProperty ("lines")]
        public string[] Lines { get; private set; }

        [JsonProperty ("winning_number")]
        public int WinningNumber { get; private set; }

        [JsonProperty ("new_type")]
        public NewType NewType { get; private set; }

        [JsonConstructor]
        private MyNewPayload (string name, string[] lines, int winningNumber, NewType newType)
        {
            Name = name;
            Lines = lines;
            WinningNumber = winningNumber;
            NewType = newType;
        }
    }

    public class NewType
    {
        [JsonProperty ("nested_type")]
        public NestedType NestedType { get; private set; }

        [JsonConstructor]
        private NewType (NestedType nestedType)
        {
            NestedType = nestedType;
        }
    }

    public class NestedType
    {
        [JsonProperty ("id")]
        public float Id { get; private set; }

        [JsonConstructor]
        private NestedType (float id)
        {
            Id = id;
        }
    }
}

Serialize C# types to JSON text, from within Visual Studio

Convert your C# payload types into JSON, using default values as needed.
For example:

public class HandleMaterial
{
    public int MaterialName { get; }

    public HandleMaterial (int materialName)
    {
        MaterialName = materialName;
    }
}


public class HandleData
{
    public float Strength { get; }

    public HandleMaterial Material { get; }

    [JsonIgnore]
    public Handle Handle { get; private set; }

    public HandleData (float strength, HandleMaterial material)
    {
        Strength = strength;
        Material = material;
    }
}

can be converted via the right-click context menu, ser-cs to automatically generate this JSON snippet:

{
  "strength": 0.0,
  "material": {
    "material_name": 0
  }
}

Installation and Usage

Download the JsonButlerIde.vsix file from the Github releases page.
Install the Visual Studio extension by running the .vsix file.
This may also open up a dialog box that lets you choose which Visual Studio version you want to install this extension into.

Coming soon (maybe): A direct download from the Visual Studio Marketplace.

Feedback and Contribution

Please feel free to send in a Pull Request, or drop me an email. Cheers!

About

Visual Studio extension that adds several JSON-conversion features within the IDE. Generate C# types from JSON. Serialize C# types to JSON (within code editor). Change cases of phrases.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published