Home:ALL Converter>JavaScript generating heading with special characters JSON

JavaScript generating heading with special characters JSON

Ask Time:2020-04-04T20:07:33         Author:Sebastian Claes

Json Formatter

I have a problem with special characters. my JavaScript is generating a image gallery. It is also generating a heading for the gallery and this heading is produced from the directory path name. The heading is basicly the folder name in which the images are. My problem is, that some of the folder names has special characters and this is causing some problems with generating the gallery heading.

Below you can see cutout from my code. Would be great if somebody can help me :) Thanks and sorry for the bad english.

    jQuery.getJSON("/images/galerie", function(galerie_index){

        for(let gi in galerie_index){

            let entry = galerie_index[gi];

            if(entry["type"] !== "directory"){
                return;
            }
            let galerie_pfad = "/images/galerie/" + entry["name"];

            create_heading_element(entry["name"]);

            process_galerie(galerie_pfad);
        }

    });
}

function process_galerie(galerie_pfad){

    let wrapper = create_wrapper_element();

    jQuery.getJSON(galerie_pfad + "/index.json", function (image_index){
        for(let eintrag in image_index){
            create_image_element(wrapper, image_index[eintrag], galerie_pfad + "/" + eintrag);
        }

    });

}```

Author:Sebastian Claes,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/61027830/javascript-generating-heading-with-special-characters-json
yy