From f7b64190c09c32dcd55ea49e8d1d3844e7a105c7 Mon Sep 17 00:00:00 2001 From: Ernie Hershey Date: Tue, 22 Oct 2019 16:53:37 +0100 Subject: [PATCH 1/2] use brackets for dots in field names --- show_struct.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/show_struct.py b/show_struct.py index e0fdf7a..a5c021d 100755 --- a/show_struct.py +++ b/show_struct.py @@ -22,7 +22,13 @@ def _outline(self, data, path): if not data: self.values_for_path[p]['(Empty hash)'] = True for k, v in data.iteritems(): - self._outline(v, path + ['.' + k]) + if "." in k: + newpath = '["' + k + '"]' + if len(path) == 0: + newpath = '.' + newpath + else: + newpath = '.' + k + self._outline(v, path + [newpath]) return if isinstance(data, list): for v in data: From e3e2ffcfea48fc384a54481613e0d362a20ff7a3 Mon Sep 17 00:00:00 2001 From: Ernie Hershey Date: Sun, 24 Nov 2019 16:34:40 -0500 Subject: [PATCH 2/2] Also use brackets if space in field name --- show_struct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/show_struct.py b/show_struct.py index a5c021d..9838e31 100755 --- a/show_struct.py +++ b/show_struct.py @@ -22,7 +22,7 @@ def _outline(self, data, path): if not data: self.values_for_path[p]['(Empty hash)'] = True for k, v in data.iteritems(): - if "." in k: + if "." in k or " " in k: newpath = '["' + k + '"]' if len(path) == 0: newpath = '.' + newpath