JSON alternatives (for the purpose of specifying configuration)?

后端 未结 8 2524
悲&欢浪女
悲&欢浪女 2021-02-19 20:31

I like json as a format for configuration files for the software I write. I like that it\'s lightweight, simple, and widely supported. However, I\'m finding that there are some

8条回答
  •  旧时难觅i
    2021-02-19 20:42

    Have a look at http://github.com/igagis/puu/

    It is even simpler than JSON.

    It has C++ style comments.

    It is possible to format multiline strings and use escaped new line \n and tab \t chars if "real" new line or tab is needed.

    Here is the example snippet:

    "String object"
    AnotherStringObject
    "String with children"{
        "child 1"
        Child2
        "child three"{
            SubChild1
            "Subchild two"
    
            Property1 {Value1}
            "Property two" {"Value 2"}
            //comment
    
            /* multi-line
               comment */
    
            "multi-line
             string"
    
            "Escape sequences \" \n \r \t \\"
        }
    
    R"qwerty(
    This is a
    raw string, "Hello world!"
    int main(argc, argv){
        int a = 10;
        printf("Hello %d", a);
    }
    )qwerty"
    }
    

提交回复
热议问题