• Login
Community
  • Login

[New plugin] JSON escape/unescape plugin

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
2 Posts 2 Posters 3.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Alexander Verbitsky
    last edited by Aug 2, 2023, 1:54 PM

    Just finished (kinda) my first Notepad++ plugin. It has just 3 functions:

    • Escape (no surprises)
    • Unescape (no surprises)
    • Recursive unescape

    The first two are trivial, the second is interesting (at least for me because I have to work with large JSONs on daily basis). Recursive unescape scans JSON for string fields and tries to convert them to JSON objects. For example:

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

    It is useful when you have to read some JSONs like

    {
        "events": [
            {
                "event": "1",
                "data": "{\"a\":\"string\"}"
            },
            {
                "event": "2",
                "data": "{\"b\":\"string\", \"c\":42}"
            }
        ]
    }
    

    Recursive unescape transforms it to

    {
        "events": [
            {
                "data": {
                    "a": "string"
                },
                "event": "1"
            },
            {
                "data": {
                    "b": "string",
                    "c": 42
                },
                "event": "2"
            }
        ]
    }
    

    Source code: https://github.com/RolandTaverner/npp-json-escape-unescape-plugin
    Hope it will be useful not for me only. Also I will be grateful for feedback.
    PS Right now it supports UTF8 only, will fix it ASAP.

    V 1 Reply Last reply Aug 2, 2023, 2:42 PM Reply Quote 5
    • V
      Victorel Petrovich @Alexander Verbitsky
      last edited by Aug 2, 2023, 2:42 PM

      @Alexander-Verbitsky Congratulations!

      1 Reply Last reply Reply Quote 1
      2 out of 2
      • First post
        2/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors