JHson.js - Example - Get JSON From HTML

This is an example of how to get the JSON from an HTML DOM element.

Download Now

v2.3.0 - 9th Sep 2024
Code
                                    var header = document.getElementById( "header" );
                                    var textArea = document.getElementById( "json" );
                    
                                    textArea.value = $jhson
                                        .json()
                                        .includeAttributes( true )
                                        .includeDataAttributes( true )
                                        .includeCssProperties( false )
                                        .includeText( true )
                                        .includeChildren( true )
                                        .includeImagesAsBase64( false )
                                        .friendlyFormat( true )
                                        .indentSpaces( 2 )
                                        .ignoreNodeTypes( "q" )
                                        .ignoreNodeCondition( null )
                                        .ignoreCssProperties( "padding" )
                                        .ignoreAttributes( "data-your-attribute" )
                                        .generateUniqueMissingIds( false )
                                        .generateUniqueMissingNames( false )
                                        .propertyReplacer( null )
                                        .get( header );