folder Tahribat.com Forumları
linefolder Programlama Genel
linefolder [Yardim]Regex İle Kullanilmayan JSON Pair Ve Arraylarinin Silinmesi İslemi.



[Yardim]Regex İle Kullanilmayan JSON Pair Ve Arraylarinin Silinmesi İslemi.

  1. KısayolKısayol reportŞikayet pmÖzel Mesaj
    wh0
    wh0's avatar
    Kayıt Tarihi: 21/Temmuz/2008
    Homo
    {
                "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": {},

     

    wh0 tarafından 28/Şub/16 15:00 tarihinde düzenlenmiştir

    🏴‍☠️Hi'dan gelen varır Who'ya, Hi'da onun adıdır Who'da...
  2. KısayolKısayol reportŞikayet pmÖzel Mesaj
    unbalanced
    unbalanced's avatar
    Kayıt Tarihi: 14/Haziran/2006
    Erkek

    text.match(/[^\n]*(\[(\n)*\]|\{(\n)*\})[^\n]*/g);


    Ülkesini Seven Her Türk Vatandasi, Ülkesinin Sessiz Istilasi'na karsi durmak zorunda.
  3. KısayolKısayol reportŞikayet pmÖzel Mesaj
    babayarisi
    babayarisi's avatar
    Kayıt Tarihi: 17/Mart/2014
    Erkek
    <?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);
    ?>

     

     

  4. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Tarikat Şeyhi
    HolyOne
    HolyOne's avatar
    Kayıt Tarihi: 01/Haziran/2002
    Erkek

    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


    Nush ile uslanmayanı etmeli tekdir, Tekdir ile uslanmayanın hakkı kötektir!
  5. KısayolKısayol reportŞikayet pmÖzel Mesaj
    wh0
    wh0's avatar
    Kayıt Tarihi: 21/Temmuz/2008
    Homo

    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

    🏴‍☠️Hi'dan gelen varır Who'ya, Hi'da onun adıdır Who'da...
  6. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Tarikat Şeyhi
    HolyOne
    HolyOne's avatar
    Kayıt Tarihi: 01/Haziran/2002
    Erkek

    Anladım da Json serialize ederken null valueları çıkar gibi bi seçenek mutlaka vardır her dilde


    Nush ile uslanmayanı etmeli tekdir, Tekdir ile uslanmayanın hakkı kötektir!
  7. KısayolKısayol reportŞikayet pmÖzel Mesaj
    PHP-SEO Developer
    Erdem
    Erdem's avatar
    Kayıt Tarihi: 04/Haziran/2002
    Erkek

    http://stackoverflow.com/questions/7741415/strip-null-values-of-json-object

    İncelemeni öneririm.


    Php for SEO nun ardından Php for Gcode (CNC)
Toplam Hit: 1320 Toplam Mesaj: 7
regex remove item