Json Datei prüfen und Werte anpassen

  • Hallo,


    und wieder stolpere ich einmal über ein Problem beim parsen einer json. Diese hier kann ich nicht auslesen und daher auch nicht anpassen. Dabei geht es um die beiden url am Ende


    {
     "LetsEncryptACME": {
       "UseLetsEncrypt": false,
       "DomainToUse": "WINDOWS-NQT7J6G .",
       "EmailAddress": "email@example.com",
       "CountryName": "Country",
       "Locality": "language",
       "Organization": "your Organization",
       "OrganizationUnit": "your Organization Unit",
       "State": "state"
     },
     "AppSettings": {
       "Secret": "8b7ca344-72cf-4dd6-9401-15e5ac077b13ef26ed76-db40-4e41-a857-a15207d75515d0f92628-2fbb-49e6-9ae8-c7624cea6695b2b53278-d2bc-4aeb-ba89-3255e8026cc2c1109914-8588-4c24-9261-734b5d34e5bd" /* if you change it all old passwords are not readable anymore, so delete the Users.DB file */
     },
     "Kestrel": {
       "Endpoints": {
         "Http": {
           "Url": "http://WINDOWS-NQT7J6G .:80"
           //"Url": "http://WINDOWS-NQT7J6G .:5000"
           //"Url": "http://192.168.22.176:80"
           //"Url": "http://192.168.22.176:5000"
           //"Url": "http://localhost:5000"
           //"Url": "http://127.0.0.1:5000"
         },
         "HttpsDefaultCert": {
           "Url": "https://WINDOWS-NQT7J6G .:443"
           //"Url": "https://WINDOWS-NQT7J6G .:5001"
           //"Url": "https://192.168.22.176:443"
           //"Url": "https://192.168.22.176:5001"
           //"Url": "https://localhost:5001"
           //"Url": "https://127.0.0.1:5001"
         }
       }
     }
    }

  • Kommentare (die //-Zeilenanfänge sowie die /*/*/-Kombinationen) sind in keinem maßgeblichen JSON-Standard (RFC 8259 / ECMA-404 / STD 90) - und damit auch in der UDF - erlaubt.
    Der JSON-String ist ergo kein gültiger JSON-String.

    Vor dem Prozessieren musst du also die Kommentare z.b. per RegEx entfernen.

  • Nun, ich hatte die Kommentarzeilen mit folgendem bereits entfernt


    If _FileReadToArray($sInputFile, $aLines) Then
       Local $sNewText = ""
       For $i = 1 To $aLines[0]
           If Not StringRegExp($aLines[$i], '^\s*//') Then
               $sNewText &= $aLines[$i] & @CRLF
           EndIf 

    Next
        EndIf


    leider kam ich trotzdem zu keinem Ergebnis.

    Einmal editiert, zuletzt von schlawiner (27. Mai 2026 um 16:38)

  • Du hast nur die reinen Kommentarzeilen entfernt. Der folgende Kommentar ist weiterhin Teil des JSON-Strings:

    Code
    /* if you change it all old passwords are not readable anymore, so delete the Users.DB file */

    Edit: Hier mal als vollständiges Skript:

    Einmal editiert, zuletzt von AspirinJunkie (27. Mai 2026 um 20:59)