Code Monkey home page Code Monkey logo

pretty-json's People

Contributors

pineli avatar warfares 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  avatar  avatar  avatar  avatar  avatar  avatar

pretty-json's Issues

Improvement: Specify underscore template settings

Hey, great library.

I had a problem where a project had used underscore _.templateSettings to change the default behavior.

Problem is that in your library you do your templates based on the default settings, so if someone overrides it, it wont work.

A minor improvement would be for this library to specify its template settings directly.

_.template(templateString, [data], [settings])

Just create an obj with the default settings

{
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
}

(I already fixed in my project by using the solution above, to not interfere with your library, but a library shouldnt depend on that to work)

Strings are not HTML escaped when rendered

The text within a string leaf value is not HTML escaped when rendered, which leaves this open to scripting attacks, and minor UI failures like so:

{
    "name": "John Doe <[email protected]>"
}

Which renders to:

{
name :  "John Doe "
}

One could also do something malicious like:

{
    "name": "John Doe <script>alert('I am bad!')</script>"
}

Which will execute the arbitrary script. This can be fixed simply by changing the Leaf underscore template to escape the data with a <%-data%>< instead of <%=data%>.

Optional sorting of keys

Any chance you could add support for displaying the keys in sorted order?

Perhaps by adding support for a callback so the caller can handle various sort cases?

Improvement - Style specific attributes

For example, it'd be great to add a node and bold it above others.

My specific case includes making a sample JSON payload, and I would like to bold what's mandatory and what's not.

collapseAll() - level

Hi there,

First of all, this library is awesome and it has no competitive libs. Well done mate!

I ran into a case where I needed to collapse all nodes including the root one. Sadly the root node is not collapsible, because this condition

if(this.level != 1)
    this.hide();

Would it be possible to add an option, something like collapseRootNode: true/false?

The reason, why it would be awesome is when you have a table (grid) and one of the columns is json, it's not possible to collapse it, so the row column is huge instead of just "{....}".

e3508765b2526700d61617d4194cb4fe

Thanks in advance!

Event when parsing is done

Currently there is not event when the parsing has been completed. For very large JSON file this could be helpful. Thank you.

License confusion

Hi,

It appears that in your minified version, the license text from "/build/license.txt" is included in the file, but your project says that it's licensed under the MIT License.
Can you please clarify this (and place a license in the header of all your files?).
Thank you.

Display elements in quotes

It would be very nice if there was an option to enable quotes around elements, this is especially useful when pasting this json back into a strict json parser.

eg.

{
"node": "value"
}

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.