Skip to content

RolandTaverner/npp-json-escape-unescape-plugin

Repository files navigation

About

This is a Notepad++ plugin for escaping and unescaping JSON strings.

Installation

TL;DR: See the Official plugin installation HOWTO

Open the Releases page to view all available releases.

32-bit (x86) Notepad++

Download the latest 32-bit version (Release_x86.zip).

Unzip Release_x86.zip to %PROGRAMFILES(x86)%\Notepad++\plugins\NppJsonEscapeUnescapePlugin\NppJsonEscapeUnescapePlugin.dll.

Usually, %PROGRAMFILES(x86)% = C:\Program Files (x86).

64-bit (x86-64) Notepad++

Download the latest 64-bit version (Release_x64.zip).

Unzip Release_x64.zip to %PROGRAMFILES%\Notepad++\plugins\NppJsonEscapeUnescapePlugin\NppJsonEscapeUnescapePlugin.dll.

Usually, %PROGRAMFILES% = C:\Program Files.

Functions

Escape

Plain and simple JSON escape.

Examples

sample "string"\ => "sample \"string\"\\"

{"a": "test"} => "{\"a\": \"test\"}"

And so on.

Unescape

Plain and simple JSON unescaping. It can unescape both some string and "some string".

Note: Input must be a valid JSON-escaped string.

Examples

"test \"string\"\\n" => test "string"\n

test \"string\"\\n => test "string"\n

{\"a\": \"123\\n\"} => {"a": "123\n"}

And so on.

Recursive unescape

This mode is a bit more complex.

If the input is "some string" or some string, it behaves like a simple unescape (see above).

If the input is valid JSON (e.g. {"a": 1}) or valid escaped JSON (e.g. "{\"a\": \"string\"}", with or without outer quotes), it performs the following:

  • Parses the input as JSON.
  • Recursively traverses all nodes.
  • For string nodes, attempts to parse their contents as JSON and replaces the string value with the resulting object.

Examples

"{\"a\": \"string\"}" => {"a":"string"}

{\"a\": \"string\"} => {"a":"string"} (same as above but without outer quotes)

"{\"a\":1,\"b\":\"{\\\"c\\\": 1}\"}" => {"a":1,"b":{"c":1}}

{"a": "{\"b\":\"{\\\"c\\\": \\\"string\\\"}\"}"} => {"a":{"b":{"c":"string"}}}

And so on.

How to build

Do a security audit

Since this is an open-source project from an independent developer, do not blindly trust it.

Please verify the repository before building.

Check git modules

The .gitmodules file should should reference the official JsonCpp repository.

Check *.bat files

The build_jsoncpp_x32.bat and build_jsoncpp_x64.bat files should contain only build-related commands.

Read the code

The codebase is small — just read it. There should be no suspicious elements such as network operations, process creation, or obfuscated code.

Prerequisites

Visual Studio 17 2022

  • Desktop development with C++
    • Windows SDK
    • C++ CMake tools for windows
  • Python development
    • Python 3

Get the code

git clone https://github.com/RolandTaverner/npp-json-escape-unescape-plugin.git

Build JsonCpp static libraries

You can build 32-bit (x86), 64-bit (x86-64) library versions or both if you need them all.

If Visual Studio is installed in a non-standard location, modify the path to vcvarsall.bat at the beginning of build_jsoncpp_x32.bat and build_jsoncpp_x64.bat. Alternatively, open the VS 2022 x64 Developer Command Prompt and run the build commands manually without calling vcvarsall.bat explicitly.

32-bit

Run build_jsoncpp_x32.bat.

After a successful build, the following files will be created:

  • npp-json-escape-unescape-plugin\3rdparty\jsoncppbuild\build_Win32\lib\Debug\jsoncpp.lib
  • npp-json-escape-unescape-plugin\3rdparty\jsoncppbuild\build_Win32\lib\Release\jsoncpp.lib

64-bit

Run build_jsoncpp_x64.bat.

After a successful build, the following files will be created:

  • npp-json-escape-unescape-plugin\3rdparty\jsoncppbuild\build_x64\lib\Debug\jsoncpp.lib
  • npp-json-escape-unescape-plugin\3rdparty\jsoncppbuild\build_x64\lib\Release\jsoncpp.lib

Open the solution

The solution file is located at: npp-json-escape-unescape-plugin/vs.proj/NppJsonEscapeUnescapePlugin.sln

Enjoy

Thanks to

  • Don Ho – Author of the lovely Notepad++.
  • JsonCpp Community – Authors and maintainers of theJsonCpp library.
  • Rajendra Singh – Author of the URL plugin used as a reference.
  • molsonkiko – Author of the JsonTools plugin, which I use every day.

About

Notepad++ JSON escape/unescape plugin

Topics

Resources

License

GPL-2.0, GPL-2.0 licenses found

Licenses found

GPL-2.0
LICENSE
GPL-2.0
license.txt

Stars

Watchers

Forks

Packages

No packages published