Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE REQUEST prettify at vector level #398

Open
MonteShaffer opened this issue Aug 8, 2022 · 0 comments
Open

FEATURE REQUEST prettify at vector level #398

MonteShaffer opened this issue Aug 8, 2022 · 0 comments

Comments

@MonteShaffer
Copy link

I have your object from the documentation:

{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["mynull","mycomplex","mymatrix","myint","mydf","mylist","mylogical","mychar","somemissings","myrawvec"]}},"value":[{"type":"NULL"},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["values","vectors"]}},"value":[{"type":"complex","attributes":{},"value":["0.055+1.256i","0.055-1.256i","1.007+0i"]},{"type":"complex","attributes":{"dim":{"type":"integer","attributes":{},"value":[3,3]}},"value":["-0.179+0.16i","0.697+0i","0.134+0.662i","-0.179-0.16i","0.697+0i","0.134-0.662i","0.661+0i","-0.495+0i","-0.565+0i"]}]},{"type":"double","attributes":{"dim":{"type":"integer","attributes":{},"value":[3,3]}},"value":[-0.446,1.224,0.36,0.401,0.111,-0.556,1.787,0.498,-1.967]},{"type":"integer","attributes":{},"value":[1,2,3]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["speed","dist"]},"class":{"type":"character","attributes":{},"value":["data.frame"]},"row.names":{"type":"integer","attributes":{},"value":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]}},"value":[{"type":"double","attributes":{},"value":[4,4,7,7,8,9,10,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,16,16,17,17,17,18,18,18,18,19,19,19,20,20,20,20,20,22,23,24,24,24,24,25]},{"type":"double","attributes":{},"value":[2,10,4,22,16,10,18,26,34,17,28,14,20,24,28,26,34,34,46,26,36,60,80,20,26,54,32,40,32,40,50,42,56,76,84,36,46,68,32,48,52,56,64,66,54,70,92,93,120,85]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["foo","","","",""]}},"value":[{"type":"character","attributes":{},"value":["bar"]},{"type":"double","attributes":{},"value":[123]},{"type":"logical","attributes":{},"value":[null]},{"type":"NULL"},{"type":"list","attributes":{},"value":[{"type":"character","attributes":{},"value":["test"]}]}]},{"type":"logical","attributes":{},"value":[true,false,null]},{"type":"character","attributes":{},"value":["foo",null,"bar"]},{"type":"double","attributes":{},"value":[1,2,"NA","NaN",5,"Inf","-Inf",9,"NA"]},{"type":"raw","attributes":{},"value":"VGhpcyBpcyBhIHRlc3Q="}]}

I go to https://jsonlint.com/ to validate:

{
	"type": "list",
	"attributes": {
		"names": {
			"type": "character",
			"attributes": {},
			"value": ["mynull", "mycomplex", "mymatrix", "myint", "mydf", "mylist", "mylogical", "mychar", "somemissings", "myrawvec"]
		}
	},
	"value": [{
		"type": "NULL"
	}, {
		"type": "list",
		"attributes": {
			"names": {
				"type": "character",
				"attributes": {},
				"value": ["values", "vectors"]
			}
		},
		"value": [{
			"type": "complex",
			"attributes": {},
			"value": ["0.055+1.256i", "0.055-1.256i", "1.007+0i"]
		}, {
			"type": "complex",
			"attributes": {
				"dim": {
					"type": "integer",
					"attributes": {},
					"value": [3, 3]
				}
			},
			"value": ["-0.179+0.16i", "0.697+0i", "0.134+0.662i", "-0.179-0.16i", "0.697+0i", "0.134-0.662i", "0.661+0i", "-0.495+0i", "-0.565+0i"]
		}]
	}, {
		"type": "double",
		"attributes": {
			"dim": {
				"type": "integer",
				"attributes": {},
				"value": [3, 3]
			}
		},
		"value": [-0.446, 1.224, 0.36, 0.401, 0.111, -0.556, 1.787, 0.498, -1.967]
	}, {
		"type": "integer",
		"attributes": {},
		"value": [1, 2, 3]
	}, {
		"type": "list",
		"attributes": {
			"names": {
				"type": "character",
				"attributes": {},
				"value": ["speed", "dist"]
			},
			"class": {
				"type": "character",
				"attributes": {},
				"value": ["data.frame"]
			},
			"row.names": {
				"type": "integer",
				"attributes": {},
				"value": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
			}
		},
		"value": [{
			"type": "double",
			"attributes": {},
			"value": [4, 4, 7, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 20, 20, 20, 20, 20, 22, 23, 24, 24, 24, 24, 25]
		}, {
			"type": "double",
			"attributes": {},
			"value": [2, 10, 4, 22, 16, 10, 18, 26, 34, 17, 28, 14, 20, 24, 28, 26, 34, 34, 46, 26, 36, 60, 80, 20, 26, 54, 32, 40, 32, 40, 50, 42, 56, 76, 84, 36, 46, 68, 32, 48, 52, 56, 64, 66, 54, 70, 92, 93, 120, 85]
		}]
	}, {
		"type": "list",
		"attributes": {
			"names": {
				"type": "character",
				"attributes": {},
				"value": ["foo", "", "", "", ""]
			}
		},
		"value": [{
			"type": "character",
			"attributes": {},
			"value": ["bar"]
		}, {
			"type": "double",
			"attributes": {},
			"value": [123]
		}, {
			"type": "logical",
			"attributes": {},
			"value": [null]
		}, {
			"type": "NULL"
		}, {
			"type": "list",
			"attributes": {},
			"value": [{
				"type": "character",
				"attributes": {},
				"value": ["test"]
			}]
		}]
	}, {
		"type": "logical",
		"attributes": {},
		"value": [true, false, null]
	}, {
		"type": "character",
		"attributes": {},
		"value": ["foo", null, "bar"]
	}, {
		"type": "double",
		"attributes": {},
		"value": [1, 2, "NA", "NaN", 5, "Inf", "-Inf", 9, "NA"]
	}, {
		"type": "raw",
		"attributes": {},
		"value": "VGhpcyBpcyBhIHRlc3Q="
	}]
}

Notice how the lowest level ( the "value" is a vector ), https://jsonlint.com/ does "prettify"... ALL data at the vector-level are on one line without wrapping

It is a bit different than yours. Can we have an option that allows the above, rather than the current output below:

{
    "type": "list",
    "attributes": {
        "names": {
            "type": "character",
            "attributes": {

            },
            "value": [
                "mynull",
                "mycomplex",
                "mymatrix",
                "myint",
                "mydf",
                "mylist",
                "mylogical",
                "mychar",
                "somemissings",
                "myrawvec"
            ]
        }
    },
    "value": [
        {
            "type": "NULL"
        },
        {
            "type": "list",
            "attributes": {
                "names": {
                    "type": "character",
                    "attributes": {

                    },
                    "value": [
                        "values",
                        "vectors"
                    ]
                }
            },
            "value": [
                {
                    "type": "complex",
                    "attributes": {

                    },
                    "value": [
                        "0.055+1.256i",
                        "0.055-1.256i",
                        "1.007+0i"
                    ]
                },
                {
                    "type": "complex",
                    "attributes": {
                        "dim": {
                            "type": "integer",
                            "attributes": {

                            },
                            "value": [
                                3,
                                3
                            ]
                        }
                    },
                    "value": [
                        "-0.179+0.16i",
                        "0.697+0i",
                        "0.134+0.662i",
                        "-0.179-0.16i",
                        "0.697+0i",
                        "0.134-0.662i",
                        "0.661+0i",
                        "-0.495+0i",
                        "-0.565+0i"
                    ]
                }
            ]
        },
        {
            "type": "double",
            "attributes": {
                "dim": {
                    "type": "integer",
                    "attributes": {

                    },
                    "value": [
                        3,
                        3
                    ]
                }
            },
            "value": [
                -0.446,
                1.224,
                0.36,
                0.401,
                0.111,
                -0.556,
                1.787,
                0.498,
                -1.967
            ]
        },
        {
            "type": "integer",
            "attributes": {

            },
            "value": [
                1,
                2,
                3
            ]
        },
        {
            "type": "list",
            "attributes": {
                "names": {
                    "type": "character",
                    "attributes": {

                    },
                    "value": [
                        "speed",
                        "dist"
                    ]
                },
                "class": {
                    "type": "character",
                    "attributes": {

                    },
                    "value": [
                        "data.frame"
                    ]
                },
                "row.names": {
                    "type": "integer",
                    "attributes": {

                    },
                    "value": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26,
                        27,
                        28,
                        29,
                        30,
                        31,
                        32,
                        33,
                        34,
                        35,
                        36,
                        37,
                        38,
                        39,
                        40,
                        41,
                        42,
                        43,
                        44,
                        45,
                        46,
                        47,
                        48,
                        49,
                        50
                    ]
                }
            },
            "value": [
                {
                    "type": "double",
                    "attributes": {

                    },
                    "value": [
                        4,
                        4,
                        7,
                        7,
                        8,
                        9,
                        10,
                        10,
                        10,
                        11,
                        11,
                        12,
                        12,
                        12,
                        12,
                        13,
                        13,
                        13,
                        13,
                        14,
                        14,
                        14,
                        14,
                        15,
                        15,
                        15,
                        16,
                        16,
                        17,
                        17,
                        17,
                        18,
                        18,
                        18,
                        18,
                        19,
                        19,
                        19,
                        20,
                        20,
                        20,
                        20,
                        20,
                        22,
                        23,
                        24,
                        24,
                        24,
                        24,
                        25
                    ]
                },
                {
                    "type": "double",
                    "attributes": {

                    },
                    "value": [
                        2,
                        10,
                        4,
                        22,
                        16,
                        10,
                        18,
                        26,
                        34,
                        17,
                        28,
                        14,
                        20,
                        24,
                        28,
                        26,
                        34,
                        34,
                        46,
                        26,
                        36,
                        60,
                        80,
                        20,
                        26,
                        54,
                        32,
                        40,
                        32,
                        40,
                        50,
                        42,
                        56,
                        76,
                        84,
                        36,
                        46,
                        68,
                        32,
                        48,
                        52,
                        56,
                        64,
                        66,
                        54,
                        70,
                        92,
                        93,
                        120,
                        85
                    ]
                }
            ]
        },
        {
            "type": "list",
            "attributes": {
                "names": {
                    "type": "character",
                    "attributes": {

                    },
                    "value": [
                        "foo",
                        "",
                        "",
                        "",
                        ""
                    ]
                }
            },
            "value": [
                {
                    "type": "character",
                    "attributes": {

                    },
                    "value": [
                        "bar"
                    ]
                },
                {
                    "type": "double",
                    "attributes": {

                    },
                    "value": [
                        123
                    ]
                },
                {
                    "type": "logical",
                    "attributes": {

                    },
                    "value": [
                        null
                    ]
                },
                {
                    "type": "NULL"
                },
                {
                    "type": "list",
                    "attributes": {

                    },
                    "value": [
                        {
                            "type": "character",
                            "attributes": {

                            },
                            "value": [
                                "test"
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "type": "logical",
            "attributes": {

            },
            "value": [
                true,
                false,
                null
            ]
        },
        {
            "type": "character",
            "attributes": {

            },
            "value": [
                "foo",
                null,
                "bar"
            ]
        },
        {
            "type": "double",
            "attributes": {

            },
            "value": [
                1,
                2,
                "NA",
                "NaN",
                5,
                "Inf",
                "-Inf",
                9,
                "NA"
            ]
        },
        {
            "type": "raw",
            "attributes": {

            },
            "value": "VGhpcyBpcyBhIHRlc3Q="
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant