Re DeL SiLeNziO
8th November 2013 10:42 UTC
Create a JSON variable in an NSIS script
Hi all,
I'm a new user of this forum and I'm a newbie of NSIS installer and JSON.
Unfortunately, I've to make an NSIS script that, taking values from a form in the installer, will create a JSON, in order to make an http request.
The question is, it is possible to create a json variable in nsis? All threads I've seen, talking about a json file for input, but in this case, I should have a json variable for output.
It is possible? I took a look to nsJSON plugin, but I don't know if it is the right plugin..
Thanks!
Re DeL SiLeNziO
Re DeL SiLeNziO
8th November 2013 13:49 UTC
mmm ok, I've already read this thread but I need some explaination...
the example of thread says:
nsJSON::Set `more_stuff` `PSCHED_009_NAME` /value `QoS Packet Scheduler`
in this case, where is the variable containing my data?
How can I do an http call?
Re DeL SiLeNziO
8th November 2013 16:59 UTC
I tried to use nsJSON but, when compile I obtain:
Invalid command: nsJSON::Set
this is my code:
...
!include MUI2.nsh
....
Page custom nsDialogsPage
...
Function nsDialogsPage
SetOutPath "$INSTDIR\bin"
File "..\bin\nsJSON.dll"
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Registering a new AIC"
Pop $Title
${NSD_CreateLabel} 0 20 20 12u "AIC:"
Pop $LabelAIC
${NSD_CreateText} 40 20 80 12u ""
Pop $TextAIC
${NSD_GetText} $TextAIC $prova
nsJSON::Set /value `{}`
nsJSON::Set `aic` /value `"$prova"`
nsJSON::Serialize /format /file c:\Temp\test.json
DetailPrint `Generate: c:\Temp\test.json`
nsDialogs::Show
FunctionEnd
Anders
8th November 2013 22:04 UTC
Invalid command probably means it cannot find the plugin, use !addplugindir...
Re DeL SiLeNziO
11th November 2013 11:16 UTC
Originally posted by Anders
Invalid command probably means it cannot find the plugin, use !addplugindir...
Ok!! Thanks! With addplugindir works!
In order to take the value of my ${NSD_CreateText} I used NSD_GetText:
Quote:
Re DeL SiLeNziO
13th November 2013 13:22 UTC
Ok, solved! My mistake... :(
... Var a ... ${NSD_CreateText} 40 20 80 12u "" Pop $txt
${NSD_GetText} $txt $a
nsJSON::Set /value `{}` nsJSON::Set `VARTEXT` /value `"$a"` nsJSON::Serialize /format /file c:\Temp\test.json DetailPrint `Generate: c:\Temp\test.json` but, even if I write some text in the field my var $a is empty and my json result is:
{ "VARTEXT": "" } Where is the error?! :( :cry:
thanks so much!!!! |