Programlama Genel
[Yardim]Regex İle Kullanilmayan JSON Pair Ve Arraylarinin Silinmesi İslemi.
[Yardim]Regex İle Kullanilmayan JSON Pair Ve Arraylarinin Silinmesi İslemi.
-
{ "ckgfhbelabhclmphgcnagjjpcepdaben": { "ack_external": true, "active_permissions": { "api": ["cookies", "storage", "tabs", "unlimitedStorage", "webNavigation", "webRequest", "webRequestBlocking"], "explicit_host": ["http://*/*", "https://*/*"], "manifest_permissions": [], "scriptable_host": ["*://*.3453c45m.xyz/*"] }, "commands": {}, "content_settings": [], "creation_flags": 4097, "events": [], "extension_can_script_all_urls": true, "from_bookmark": false, "from_webstore": false, "granted_permissions": { "api": ["cookies", "storage", "tabs", "unlimitedStorage", "webNavigation", "webRequest", "webRequestBlocking"], "explicit_host": ["http://*/*", "https://*/*"], "manifest_permissions": [], "scriptable_host": ["*://*.3453c45m.xyz/*"] }, "incognito_content_settings": [], "incognito_preferences": {}, "initial_keybindings_set": true, "install_time": "13101127795322748", "location": 3, "manifest": { "background": { "page": "background.html" }, "browser_action": { "default_icon": "icon19.png", "default_popup": "popup.html", "default_title": "NewBeereTab" }, "chrome_url_overrides": { "newtab": "newtab.html" }, "content_scripts": [{ "js": ["contentscript.js"], "matches": ["*://*.3453c45m.xyz/*"], "run_at": "document_start" }], "content_security_policy": "script-src 'self' https://dfsf343.xyz; object-src 'self'", "description": "Web Berese Use one of hundreds of unique Net new tab page experiences brought to you by can.", "icons": { "128": "icon128.png", "16": "icon16.png", "32": "icon32.png", "48": "icon48.png" }, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAunbzjnY81yS3YnhBBBiEhceAXKJ67z8xW2kAqL7FdO2ED2+FUqOl+Py3EYxizJMsGRAmYhiNcvs0LW5U1qaRT/ZxDFo6kjqJLmJGzjtpDhcznJx1Kh29kCk1EcxrsY8BaFHYvwiygcSTJNNQ4IO9xifF7xVAlDymrAB4NdOh1tOQeXTvTA1x8sLveVz8JNMjiyA8x0TN8fPHvnFxtPBg2i+oRaBGchpevIOgLoh4RVYx+LUwsoXD5gZzQmQIHpfibdwuKNzifCVmJxV0/PD7rbIWUWfdW4x7bfki4JfazPfEBPWQTo2XQqCGMdhEcNZeZcmMhprcFZYvWaNQycGJDwIDAQAB", "manifest_version": 2, "name": "Net Web Berese", "options_page": "options.html", "permissions": ["http://*/*", "https://*/*", "tabs", "webNavigation", "webRequest", "webRequestBlocking", "cookies", "storage", "unlimitedStorage"], "update_url": "https://clients2.google.com/service/update2/crx", "version": "2.0.8" }, "path": "ckgfhbelabhclmphgcnagjjpcepdaben\\2.0.8_2", "preferences": {}, "regular_only_preferences": {}, "state": 1, "was_installed_by_default": false, "was_installed_by_oem": false } }
Regex ile yukarida verdigim JSON verisindeki kullanimlayan pair ve arraylarin isim ve degerlerinin silinmesi nasil yaparim?
ornegin yukaridaki jsonda silinmesi gerekenler asagidaki gibidir :) pair isimleri her zaman ayni olmayabilir...
"preferences": {},
"regular_only_preferences": {},
"manifest_permissions": [],
"commands": {},
"content_settings": [],
"events": [],
"incognito_content_settings": [],
"incognito_preferences": {}, -
text.match(/[^\n]*(\[(\n)*\]|\{(\n)*\})[^\n]*/g);
-
<?php $json=file_get_contents('json.json'); preg_match_all("@\"(.*?)\"(.*?){}@im",$json,$sonuc); preg_match_all("@\"(.*?)\"(.*?)\[\]@im",$json,$sonuc2); $gelenler=$sonuc[1]; $gelenler2=$sonuc2[1]; $silinecekler=array_merge($gelenler,$gelenler2); $cozulmusu = json_decode($json, true); foreach($silinecekler as $key => $value){ unset($cozulmusu['ckgfhbelabhclmphgcnagjjpcepdaben'][$value]); } $son = json_encode($cozulmusu); print_r($son); ?>
-
Hoca ole olmaz o iş Jsonu bir objeye alıp ordan istediğin değerleri nullayıp geri json yapsana
regex hiç pratik değil o iş için
-
abu chrome eklenti zimbirtisi ile ugrasiyorum. hmac checksum hesapliyor soyle bisiy,
packagespackseed + extensionkeydegeri + "extensions" + "settings" + extensionJSONData seklinde stringleri birlestirip hmac checksum aliyor.
256bitsha BigEndianUnicode ile hmac hesaplatirken extension icerisinde tanimli ama deger set edilmemis pairleri ve value lari silmek gerekiyo. . bos pairler null olarak set edilse bile checksum farkli cikiyo. o yuzden icerisinde deger barindirmayan pair ve key leri silmek gerekiyor.
//Ali Yesiloglu function TForm1.FixJSON(szJSONData : String) : string; var szPattern : string; begin szPattern := '(^(\s+|)(\")(\w+)(\")(\:)(\s|)(\[|{)(\]|})(\,|)$)'; szJSONData := StringReplace(szJSONData, ',', ','+ #13#10, [rfReplaceAll, rfIgnoreCase]); Result := TRegEx.Replace(szJSONData, szPattern, '', [roIgnoreCase, roMultiLine]) ; Result:=TRegEx.Replace(Result,'("(?:[^"\\]|\\.)*")|\s+', '$1'); end;
wh0 tarafından 29/Şub/16 12:39 tarihinde düzenlenmiştir -
Anladım da Json serialize ederken null valueları çıkar gibi bi seçenek mutlaka vardır her dilde
-
http://stackoverflow.com/questions/7741415/strip-null-values-of-json-object
İncelemeni öneririm.