-
PROHARDVER!
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
- Linux kezdőknek
- Xbox tulajok OFF topicja
- Honor Magic V5 - méret a kamera mögött
- PROHARDVER! feedback: bugok, problémák, ötletek
- PlayStation 5
- Az AI megeszi a szoftverpiacot?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Tőzsde és gazdaság
- Kerékpárosok, bringások ide!
- További aktív témák...
- Asus G752VS Gamer laptop eladó!
- Makulátlan iPad Air 5 (M1 chip) 64GB Wi-Fi + Cellular, prémium kiegészítőkkel!
- DJI AVATA 2 Fly More Combo drón - 3 akku, garancia, FPV RC 3, sok tartozék
- szinte új iPhone 16 Plus 128GB white fehér független Apple 3 év garancia ajándék
- Samsung Galaxy A32 5G 128GB, Kártyafüggetlen, 1 Év Garanciával
- Telefon felvásárlás!! iPhone 11/iPhone 11 Pro/iPhone 11 Pro Max
- ÚJ Xiaomi Mi Robot Vacuum Mop Essential robotporszívó feltörlő 2db 1999 Ft
- DELL Precision 7540 - Intel Core i9-9980HK, RTX 3000 (nagyon erős GPU-val)
- Apple iPhone 14 Pro 128GB, Kártyafüggetlen, 1 Év Garanciával
- 121 - Lenovo Legion Pro 5 (16ARX8) - AMD Ryzen 7 7745HX, RTX 4070 - 4 év garancia
Állásajánlatok
Cég: FOTC
Város: Budapest