- Netfone
- Google Pixel topik
- Megjött a jubileumi Pixel széria
- iPhone topik
- Samsung Galaxy A56 - megbízható középszerűség
- Kínosan környezettudatos a HMD
- Samsung Galaxy S25 - végre van kicsi!
- Hivatalosnak tűnő képeken a Galaxy S25 FE
- Milyen okostelefont vegyek?
- Mi nincs, grafén akku van: itt a Xiaomi 11T és 11T Pro
-
Mobilarena
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
- Digitális PlayStation 5 // 2 darab kontrollerrel //
- Apple iPhone 11 64GB, Akku: 100%, Megkímélt, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Samsung Galaxy A33 5G 6/128GB, Megkímélt, Kártyafüggetlen, Töltővel, Dobozzal, 1 Év Garanciával!
- Nintendo Switch V2 32+128GB CFW okos! Dual Boot RP2040 Picofly Dual Boot tok + üvegfólia
- Samsung Galaxy S24 128GB, Tökéletes állapot, 100%-os akku, 2027-ig garancia
- ÁRGARANCIA!Épített KomPhone i5 14400F 32/64GB RAM RX 9060 XT 8GB GAMER PC termékbeszámítással
- Samsung Galaxy Watch Ultra Titanium Gray Használt, karcmentes, garanciával 2027. január 29-ig
- Dell USB-C, Thunderbolt 3, TB3, TB4 dokkolók (K20A) WD19TB/ WD19TBS/ WD22TB4, (K16A) TB16/ TB18DC
- ÁRGARANCIA!Épített KomPhone Ryzen 5 7600X 32/64GB RAM RX 7800 XT 16GB GAMER PC termékbeszámítással
- Fujitsu LIFEBOOK E449 i5-8250U 8GB 256GB 14" FHD 1 év garancia
Állásajánlatok
Cég: FOTC
Város: Budapest