-
Fototrend
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
Sk8erPeter
nagyúr
Szívesen!

Innen érthető meg elég jól, mit is csinál a JSON.parse(), lényegében hasonló az eval()-hoz, csak az a nagy különbség, hogy a JSON.parse() nem engedi lefutni pl. az esetlegesen kártékony JavaScript-kódot. Az eval()-nak pedig épp ez a nagy veszélye, hogy rajta keresztül lefuthatnak a rosszindulatú kódok.
Idézet:
"To convert a JSON text into an object, you can use the eval() function. eval() invokes the JavaScript compiler. Since JSON is a proper subset of JavaScript, the compiler will correctly parse the text and produce an object structure. The text must be wrapped in parens to avoid tripping on an ambiguity in JavaScript's syntax.
var myObject = eval('(' + myJSONtext + ')');The eval function is very fast. However, it can compile and execute any JavaScript program, so there can be security issues. The use of eval is indicated when the source is trusted and competent. It is much safer to use a JSON parser. In web applications over XMLHttpRequest, communication is permitted only to the same origin that provide that page, so it is trusted. But it might not be competent. If the server is not rigorous in its JSON encoding, or if it does not scrupulously validate all of its inputs, then it could deliver invalid JSON text that could be carrying dangerous script. The eval function would execute the script, unleashing its malice.
To defend against this, a JSON parser should be used. A JSON parser will recognize only JSON text, rejecting all scripts. In browsers that provide native JSON support, JSON parsers are also much faster than eval. It is expected that native JSON support will be included in the next ECMAScript standard.
var myObject = JSON.parse(myJSONtext, reviver);"
Új hozzászólás Aktív témák
- WD Black SN850X 8TB M.2 NVME PCI-E 4.0 x4 - Új, 1 év garancia - 7200-6600 MBs - Eladó!
- 16GB DDR4 PC MEMORIA MODUL(4X4GB, 2X8GB) RAM / SZÁMLÁVAL, GARANCIÁVAL
- Szép Kis játékos HP,Core i7 10510u(8X4,9Ghz)MX 2/4GB DDR5 VGA,FullHD IPS,16-32GB RAM/256-512SSD
- Megkímélt ThinkPad Ryzen 5 Pro(12x4,0Ghz)16-32RAM/256-512SSD,100% akku,vil.bilI.
- Lenovo Thinkpad P50 15,6" FHD IPS kijelző, I7-6820HQ CPU, 16GB DDR4, 512GB NVMe SSD, 4GB Quadro VGA,
- Apple iPhone 16 Pro Max 256GB Black Titanium használt, karcos kijelző 91% akku - 6 hó garancia
- Azonnali készpénzes Microsoft XBOX Series S és Series X felvásárlás személyesen/csomagküldéssel
- Sosemhasznált! HP OmniBook 5 Flip i5-1334U 16GB 1000GB 14" FHD+ áthajtós-érintős Gar.: 1 év
- BESZÁMÍTÁS! Apple iPad Pro 11 M4 2024 256GB Wifi tablet extrákkal garanciával hibátlan működéssel
- AKCIÓ!!! SÁRGA! -20%!!! MACBOOK NEO!!!! - MAGYAR BILLES! - CITRUS AJÁNDÉKKAL!
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

