Skip to content

Borisas/cpp-json-prettify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

json-prettify

C++. Make ugly json string into a readable pretty json string.

What does it do:

Turns this:

{"a":4,"b":{"p":"2","d":4,"e":[1,2,3]},"c":["t",4,2,3,{"a":1,"b":2}]}

Into this:

{
    "a" : 4,
    "b" : {
        "p" : "2",
        "d" : 4,
        "e" : [
            1,
            2,
            3
        ]
    },
    "c" : [
        "t",
        4,
        2,
        3,
        {
            "a" : 1,
            "b" : 2
        }
    ]
}

How to use:

    #include "JSONPrettify.h"

This one doesn't add spaces inbetween colons.

    std::string json = "... some json data ...";
    std::string pretty = boris::JSONPrettify( json );

Neither does this one

    std::string json = "... some json data ...";
    std::string pretty = boris::JSONPrettify( json , boris::Colons::TIGHT );

This one adds spaces inbetween colons. Spaces inbetween colons aren't fully complete - if you have colons in the middle of variable names or values it will put spaces. ie.: "a:b":1 -> "a : b" : 1

    std::string json = "... some json data ...";
    std::string pretty = boris::JSONPrettify( json , boris::Colons::SPACED );

About

C++11. Make ugly json string into a readable pretty json string.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages