Search code examples
nsis

Using NSIS, How can the user modify it to contain more than 8192Bytes?


Thanks for reading my article :]

I received a response using http communication, but it was upgraded because it is more than 1024 bytes. So, the Byte of ${NSIS_MAX_STRLEN} became 8192. However, an error occurs because the return value of Json type that I receive exceeds 8192 bytes. What setting should I set to get more bytes?


Solution

  • You can't put the entire JSON in a NSIS string, you must use the plug-in to find the values you need:

    This is able to parse more than 9000 bytes:

    !macro prepare_example
    FileOpen $1 "$temp\!tempjson.txt" w
    FileWrite $1 "["
    ${For} $3 1 500
        ${IfThen} $3 U> 1 ${|} FileWrite $1 "," ${|}
        FileWrite $1 '{"Return":"$3", "Out":"Any Request"}$\n'
    ${Next}
    FileWrite $1 "]"
    FileSeek $1 0 END $2
    FileClose $1
    DetailPrint "About to parse $2 bytes of JSON..."
    !macroend
    
    !include LogicLib.nsh
    Section
    !insertmacro prepare_example
    
    ClearErrors
    nsJSON::Set /file "$temp\!tempjson.txt"
    ${IfThen} ${Errors} ${|} Abort "nsJSON::Set failed" ${|}
    nsJSON::Get /count /end
    ${IfThen} ${Errors} ${|} Abort "nsJSON::Get failed" ${|}
    Pop $1
    DetailPrint Count=$1
    ${IfThen} $1 <> 0 ${|} IntOp $1 $1 - 1 ${|}
    ${For} $3 0 $1
        nsJSON::Get /index $3 /end
        ${IfThen} ${Errors} ${|} Abort "nsJSON::Get failed" ${|}
        Pop $2
        DetailPrint Object=$2
    ${Next}
    
    ${For} $3 0 $1
        nsJSON::Get /index $3 "Return" /end
        ${IfThen} ${Errors} ${|} Abort "nsJSON::Get failed" ${|}
        Pop $2
        DetailPrint Object.Return=$2
    ${Next}
    SectionEnd