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

Updated json pane to accept single quote #2143

Merged
merged 3 commits into from
Apr 7, 2021
Merged

Updated json pane to accept single quote #2143

merged 3 commits into from
Apr 7, 2021

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Apr 4, 2021

Fixes #1798

Trying to use literal_eval for the object and then json.dumps. This PR also makes it possible to be more flexible with the object.

The only thing I'm not completely sure about is if overlook something with the removal of .replace(/(\r\n|\n|\r)/gm, "").

import panel as pn

json1 = pn.pane.JSON(object={"test": "can't show this"})
json2 = pn.pane.JSON(object=["can't show this"])
json3 = pn.pane.JSON(object="can't show this")
json4 = pn.pane.JSON(object="can show this")
json5 = pn.pane.JSON(object='{"b": 3}')
json6 = pn.pane.JSON(object="{'b': 3}")

pn.Column(json1, json2, json3, json4, json5, json6).servable()
Without the PR With the PR (literal_eval) With the PR (json.loads)
2021-04-04 15_24_39 2021-04-04 15_25_19 2021-04-05 14_52_45

@codecov
Copy link

codecov bot commented Apr 4, 2021

Codecov Report

Merging #2143 (1b3f7f1) into master (4533a60) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2143      +/-   ##
==========================================
+ Coverage   83.80%   83.81%   +0.01%     
==========================================
  Files         182      182              
  Lines       21658    21672      +14     
==========================================
+ Hits        18151    18165      +14     
  Misses       3507     3507              
Impacted Files Coverage Δ
panel/pane/markup.py 97.19% <100.00%> (+0.03%) ⬆️
panel/tests/pane/test_markup.py 99.33% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4533a60...1b3f7f1. Read the comment docs.

panel/pane/markup.py Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit 31b5350 into holoviz:master Apr 7, 2021
@hoxbro hoxbro deleted the update_json_pane branch April 7, 2021 09:36
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

Successfully merging this pull request may close these issues.

Quote conversion in JSON pane breaks valid JSON content
2 participants