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

Boolean value #32

Closed
thBoo39 opened this issue Jan 3, 2018 · 5 comments
Closed

Boolean value #32

thBoo39 opened this issue Jan 3, 2018 · 5 comments

Comments

@thBoo39
Copy link

thBoo39 commented Jan 3, 2018

I found this tool quite useful.

Only problem I have is it doesn't convert Boolean value, casting empty.
For example, I tried this json code in JSON Editor Online and it properly shows what I expected.

{
  "Example": {
    "HF": {
        "before": true,
        "after": false
    }
  }
}

However, when I used this tool, it doesn't show any Boolen value.

@muellermichel
Copy link
Contributor

muellermichel commented Jan 5, 2018

OK, not sure anymore why this is, but on my fork it works:

>>> json2html.convert({"Example":{"HF": {"before": True, "after": False}}})
u'<table border="1"><tr><th>Example</th><td><table border="1"><tr><th>HF</th><td><table border="1"><tr><th>after</th><td>False</td></tr><tr><th>before</th><td>True</td></tr></table></td></tr></table></td></tr></table>'

>>> json2html.convert('{"Example":{"HF": {"before": true, "after": false}}}')
u'<table border="1"><tr><th>Example</th><td><table border="1"><tr><th>HF</th><td><table border="1"><tr><th>before</th><td>True</td></tr><tr><th>after</th><td>False</td></tr></table></td></tr></table></td></tr></table>'

While on origin/master it does indeed come out empty for the bools:

 >>> json2html.convert('{"Example":{"HF": {"before": true, "after": false}}}')
u'<table border="1"><tr><th>Example</th><td><table border="1"><tr><th>HF</th><td><table border="1"><tr><th>before</th><td></td></tr><tr><th>after</th><td></td></tr></table></td></tr></table></td></tr></table>'

>>> json2html.convert({"Example":{"HF": {"before": True, "after": False}}})
u'<table border="1"><tr><th>Example</th><td><table border="1"><tr><th>HF</th><td><table border="1"><tr><th>after</th><td></td></tr><tr><th>before</th><td></td></tr></table></td></tr></table></td></tr></table>'

Update: It's strange, I've looked through the diff again and I haven't yet found where the bug comes from. @softvar: would you agree that the code snippets above should become unit tests?

@thBoo39
Copy link
Author

thBoo39 commented Jan 16, 2018

It seems the problem exists in live demo version.
I installed the json2html v1.2.1 through pip. The converted html shows the Boolean value.

If the live demo version is fixed, it is quite handy.

@muellermichel
Copy link
Contributor

@softvar : if you pull the following PR it should be fixed. Once I get a free minute I'll make a test case out of my commands above, so I recommend leaving this issue open until that is done.

@softvar
Copy link
Owner

softvar commented Jan 26, 2018

@thBoo Thanks for letting me know. The demo was using an older version of json2html. Now it's using json2html@1.2.1 which outputs correct result.

@muellermichel #31 is not related to this issue but I'll surely gonna review it.

@softvar softvar closed this as completed Jan 26, 2018
@muellermichel
Copy link
Contributor

I c. Strangely enough I was able to reproduce OP's issue in what I thought was the latest master. Maybe my master wasn't up to date locally.

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

3 participants