Search code examples
jsonvisual-studioediting

Edit Hex values in JSON file in Visual Studio


I'm using a JSON file to configure settings in my app. Some of the settings I would like to enter as hex values.

I using Visual Studio to edit the JSON file. But when I enter a hex values it assumes that it's a string rather than a hex values and therefore it puts the value in quotation marks.

This also happens when I copy and paste JSON values that contains hex values.

Is there a way to avoid this?


Solution

  • If you want to disable the "auto-correction" in VS from changing 0x0F to "0x0F", including when copying and pasting JSON values ​​that contain hex values, you need to complete the following:

    Open your VS, Tools > Options > Text Editor > JSON > Advanced > Formatting, then change both Automatic formatting and Format on paste to Off.