0

ボタンをクリックすると、関数「DeleteFromlocalStorage」にパラメータ「id」がロードされます。これは私の機能「DeleteFromlocalStorage」です:

        function DeleteSessionFromLocalStorage(data)
    {
        var id_session = data;

        a = localStorage.getItem('session');

        alert(a);

    }

私のalert(a);出力は次のとおりです。

{"21114":{"id":"21114","external_id":"","sessiongroupid":"1844","eventid":"5588","order":"0","name":" localStorage HTML5 セッション","description":"localstorage","starttime":"2013-04-23 12:00:00","endtime":"2013-04-23 13:30:00","speaker" :"","location":"","mapid":"0","xpos":"0.000000","ypos":"0.000000","maptype":"plan","imageurl":"", "プレゼンテーション":"","主催者":"0","twitter":"","allowAddToFavorites":"0","allowAddToAgenda":"0","votes":"0","url":"","venueid":"0"}, "21115 :{"id":"21115","external_id":"","sessiongroupid":"1845" ,"eventid":"5588","order":"0","name":"tweede","description":"tweede","starttime":"2013-04-03 00:00:00", "endtime":"2013-04-04 00:00:00","speaker":"","location":"","mapid":"0","xpos":"0.000000","ypos" :"0.000000","maptype":"計画","imageurl":"","プレゼンテーション":"","主催者":"0","twitter":"","allowAddToFavorites":"0","allowAddToAgenda":"0","votes":"0","url":"","venueid":"0"},"21118":{"id":"21118 ","external_id":"","sessiongroupid":"1848","eventid":"5588","order":"0","name":"javascript セッション","description":"javascript に関するセッション","starttime":"2013-05-15 12:00:00","endtime":"2013-05-15 12:30:00","speaker":"","location":"waregem" ,"mapid":"0","xpos":"0.000000","ypos":"0.000000","maptype":"計画","imageurl":"","プレゼンテーション":"","主催者":"0","twitter":"","allowAddToFavorites":"0","allowAddToAgenda":"0","投票":"0","url":" ","venueid":"0"}}

ご覧のとおり、json文字列があります。キーは常に ID です。ここで、id = パラメータ id の json を削除したいと思います。

オブジェクトを取得してサブオブジェクトを削除し、オブジェクトを localStorage に復元する必要があります。どうすればこれができるか知っている人はいますか?

前もって感謝します!

4

3 に答える 3