2015-10-13 154 views
0

我有兩種對象,Beam和Sample。樣品包含2個光束,並且我有一個樣品陣列。我需要將數組存儲到本地存儲中,所以我打電話給localStorage["samples"] = JSON.stringify(samples);,但是我收到錯誤「將圓形結構轉換爲JSON」。我的對象不包含它自己。我也試着用對象代替samples對象,但得到相同的錯誤,並且Beam只有整數和字符串值。將圓形結構轉換爲JSON

編輯

這裏有對象。

function FlexuralStrengthT97(result, method, beam1, beam2, waitForCuring, averageBeams) { 
     this.Result = result; 
     this.Method = method; 
     this.Beam1 = beam1; 
     this.Beam2 = beam2; 
     this.WaitForCuring = waitForCuring; 
     this.AverageOfBeams = averageBeams; 

     return this; 
    } 


    function FSBeam(testingMachineId, beamAge, widthU, widthC, widthL, widthAverage, depthR, depthC, depthL, depthAverage, maxLoad, fs, psi, breakOutside) { 
     this.TestingMachineId = testingMachineId; 
     this.BeamAge = beamAge; 
     this.WidthUpper = widthU; 
     this.WidthCenter = widthC; 
     this.WidthLower = widthL; 
     this.WidthAverage = widthAverage; 
     this.DepthRight = depthR; 
     this.DepthCenter = depthC; 
     this.DepthLeft = depthL; 
     this.DepthAverage = depthAverage; 
     this.MaxLoad = maxLoad; 
     this.FS = fs; 
     this.PSI = psi; 
     this.BreakOutside = breakOutside; 

     return this; 
    } 
+0

你能提供你的物品嗎? – Grundy

+1

聽起來像'Bearn'有一個屬性指向包含它的'Sample'。這創建了一個間接循環。 – Barmar

+0

@taxicala我沒有任何JSON,這是它崩潰的地方。 –

回答

1

那些似乎是構造函數,確保與new關鍵字使用它們:

var beam1 = new FSBeam(); 
var flex = new FlexuralStrengthT97(); 

否則,thiswindow,而不是實例範圍。

相關問題