Giter Site home page Giter Site logo

alenaksu / json-viewer Goto Github PK

View Code? Open in Web Editor NEW
145.0 3.0 25.0 1.5 MB

Web Component to visualize JSON data in a tree view

Home Page: https://alenaksu.github.io/json-viewer/

License: MIT License

HTML 10.97% JavaScript 27.71% CSS 23.54% TypeScript 37.79%
json webcomponent json-viewer jsonviewer json-tree

json-viewer's People

Contributors

acarapetis avatar alenaksu avatar jakobteske avatar next-ricardoperezgamo avatar vicb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

json-viewer's Issues

Missing files

Great component. I updated to the latest. It seems that npm only publishes 3 files now -- no js files.

Feature Request: CSS variable for padding

I would like to request a CSS variable be added for padding to the wrapping shadow DOM element (ul tag), so one can add a little space to the content, especially when it's long and needs to scroll. Thanks!

License file missing

The Readme has a badge, which indicates, that this project has an MIT license, but the license does not exist and the link in the README therefore returns a 404 Not found.

Is this intentionally, or should I make a pull request which readds the MIT License file?

search always scrolls document.body

Even though my element is deeply embedded in my html page structure, when I search for a value using viewer.search() it scrolls the whole document.body not the viewer element causing vertical page movement.

Similarly when initially loading the viewer with data it scrolls document.body around 20 pixels to the left.

display property with html markup

Hi, first I'd like yo thank you for a great piece of code.

Some json objects may have properties that contain html markup, i.e. a link to a page, like in the address property below.

{
"widget": {
"debug": "on",
"window": {
"title": "a window title",
"address": "Goto",
"name": "main_window",
"width": 500,
"height": 500
}
}
It would be nice, if the viewer can have a special csspart to render the markup as is .

Thanks
Michel
[email protected]

Not working in browser after 1.0.0

Describe the bug
After 1.0.0 json view is not rendered in browser with following error.

Uncaught SyntaxError: Unexpected token 'export' (at JsonViewer.js:45:94)

Error message indicates that it is an ESM module and i tried to add type="module" attribute to script tag but it did not work too. I couldn't find anyhing about ESM change in releases page and readme.
Then i tried to use index.js file from demo and it worked with type="module attribute.
I think demo is using a custom file. It would be better to use latest distributed file in demo to detect issues early.

To Reproduce
Steps to reproduce the behavior:

  1. Copy the code below to JSFiddle
  2. Enable the script with version 0.3.4
  3. ✔️ Json view shoud be rendered
  4. Enable the script from gibhub.io which is used in demo site
  5. ✔️ Json view shoud be rendered
  6. Enable the script with version 1.0.1
  7. 🔴 You will only see json as text not json view

Link to Minimal Reproducible Example

<json-viewer>
{"widget":{"debug":"on","window":{"title":"Sample Konfabulator Widget","name":"main_window","width":500,"height":500},"image":{"src":"Images/Sun.png","name":"sun1","hOffset":250,"vOffset":250,"alignment":"center"},"text":{"data":"Click Here","size":36,"style":"bold","name":"text1","hOffset":250,"vOffset":100,"alignment":"center","onMouseUp":"sun1.opacity = (sun1.opacity / 100) * 90;"}}}
</json-viewer>

<!-- <script src="https://unpkg.com/@alenaksu/[email protected]/dist/index.js"></script> -->
<!-- <script type="module" src="https://alenaksu.github.io/json-viewer/index.js"></script> -->
<!-- <script type="module" src="https://unpkg.com/@alenaksu/[email protected]/dist/JsonViewer.js"></script> -->

Expected behavior
It should render tree view

Bug: When updating data dynamically, the library throws JSON.parse errors

What

When we're not using the <json-viewer> with any content, and rather just using the data attribute to dynamically update data. It throws the following error:
Screenshot 2022-06-13 at 20 47 41

Example usage:

  <json-viewer class="p-4" data={props.response?.data}></json-viewer>

In this case, the error is thrown.

More context

I'm using this in a SolidJS app where the data attribute gets updated throughout the app's usage.

Expected behavior

Should not throw an error in this case and should allow to just use of the data attribute for rendering.

Polymer 3 Support

Hi, can I use this component in polymer 3?
I've problem when import this component in my polymer 3 project.
Module not found: Error: Can't resolve '@alenaksu/json-viewer'

Best Regards,
Reja

demo not working

I cant get the demo to run

this is what i see..
the console says [404] Not Found (/static/styles.js)

image

How to use in with just index.js?

I tried the example, however the component just displays “null”.

I referenced the index.js and css files from the build folder, are those the wrong files?

Search in deeply nested JSON structure

Having a big or deeply nested JSON on page it's real hard to find something specific in it.
It would be really useful to have a way to search everywhere in JSON.

image

Maybe a quick but effective solution could be an "expand/collapse all" button and then we can search with native browser feature.

Allow setting data asynchronously

Excellent component!

I find that if I do a dynamic import of your library, and while the import is downloading, set data (before the custom element has had the chance to get registered), the data is lost after the component is initiated.

You might find this document helpful, search for "_upgradeProperty()"

Possible issue outputting dates from nested object

Hi there, thanks for this great component!

I'm running into an issue where sometimes my nested dates are showing as empty objects. I can't seem to pin down exactly why this is happening but will try and take another look at the source code.

For now I'm working around this by checking my structures for dates and formatting them ahead of time.

Thanks again (comparison with JSON.stringify below)

Screenshot 2022-02-16 at 21 26 34

make filter less rigid

Is your feature request related to a problem? Please describe.
my array of json has address_1, address_2, address_3 it's a pain to pass a filter string to get all 3

Describe the solution you'd like
ideally I could filter('addr') and any key/value pair with those 4 consecutive letters would remain while everything else gets hidden.

Describe alternatives you've considered
right now i just do **.entire_field_name

Additional context
Might need to put this functionality behind an option like filterMode(...) which allows users to keep the exact (default), or fuzzy (generous filter matching both keys and values with partial strings)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.