My JSON file has %20, %3A characters and when I fetch data in React.js it shows the % characters instead of decoding

I am using React.js and have a questions.JSON file in which I store the data. Now the data in the JSON file is encoded with % characters but when I fetch the data from the file, it shows up with the % characters.

Here’s the JSON file example:

    "category": "Entertainment%3A%20Video%20Games",
    "type": "multiple",
    "difficulty": "hard",
    "question": "What%20was%20the%20name%20of%20the%20hero%20in%20the%2080s%20animated%20video%20game%20%27Dragon%27s%20Lair%27%3F",
    "correct_answer": "Dirk%20the%20Daring",
    "incorrect_answers": [

Here’s the React code:

  const getData = () => {
    fetch('questions.json', {
    headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    .then(function (response) {
    return response.json()
    .then(function (myJson) {
  useEffect(() => {
  }, [])

I’m quite new to React.js so if I am missing something obvious, please be patient with me.

Source: JavaSript – Stack Overflow

September 10, 2021
Category : News
Tags: character-encoding | encoding | javascript | json | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.