前提・実現したいこと
いつもお世話になっております。
今回、外部においてあるjsonファイルを、JQueryのgetJSONで取得し、
用意してある配列に順番にpushしていくという処理を、
ファイル内に含まれている\nを、<br>に置換してpushするというように
改修したいと考えています。
色々調べながら実装してみましたがいまいちうまくいかず、
皆様の知見をお借りしたく思い、質問させていただきます。
発生している問題・エラーメッセージ
コンパイルエラーやメッセージは出ないものの、置換できていない
該当のソースコード
JavaScriptソースコード
1/* replacer関数 */ 2 function replacer(key,value){ 3 var str = new String(value); 4 str.replace(/\n/g, "<br>"); 5 console.log(str); 6 return str; 7 } 8 9 /* jsonファイルの取得関数 */ 10 function jsonLoader(){ 11 $.getJSON({ 12 type: 'GET', 13 url: 'jsonファイルの格納場所', 14 dataType: 'json', 15 async: false, 16 }).done(function(json, textStatus, jqXHR) { 17 JSON.stringify(json,replacer,"\t"); 18 console.log(json); 19 for(var i = 0; i < json.length; i++){ 20 myQuestions.push({ 21 'question': json[i].question, 22 'answers': json[i].answers, 23 'details': json[i].details, 24 'correctAnswer': json[i].correctAnswer 25 }); 26 }; 27 }).fail(function(jqXHR, textStatus, errorThrown){ 28 alert(errorThrown); 29 }); 30 }
試したこと
replace関数を用いてみましたがうまく動作しませんでした。
現在JSON.stringify(json,replacer,"\t");で定義したreplacer関数を呼び出していますが
うまくいっていません。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/10 07:05
2019/01/10 07:08
2019/01/10 07:36