Old 6th October 2021, 11:12   #1
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
read json without nsjson

can we read a JSON file in NSIS without using nsjson plugin?
shekara is offline   Reply With Quote
Old 6th October 2021, 11:31   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
NSIS does not have native JSON support, you are stuck with the plug-in.

If the file is really small and simple you might be able to use the NSIS file and string instructions but I don't really recommend it.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th October 2021, 13:31   #3
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
I am sorry for the basic questions. I have this in my json file
{
"BLD_BRH" : "****",
"RLS_STR" : "****",
"RLS_FIXED" :
}
i am setting this nsJSON::Set /file $EXEDIR\manifest.json . but I just need to read BLD_BRH and RLS_FIXED. I don't see anything here in examples
shekara is offline   Reply With Quote
Old 6th October 2021, 15:47   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
PHP Code:
Section
InitPluginsdir
FileOpen 
$"$PluginsDir\temp.txt" w
FileWrite 
$'{"BLD_BRH" : "1234","RLS_STR" : "5678","RLS_FIXED" : "invalid example"}'
FileClose $0
nsJSON
::Set /file "$PluginsDir\temp.txt"

nsJSON::Get "BLD_BRH" /end
Pop 
$0
MessageBox mb_ok 
$0
SectionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th October 2021, 10:46   #5
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
will check this out..... thank you
shekara is offline   Reply With Quote
Old 11th October 2021, 16:08   #6
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
I don't want to write anything. there is already a file that I just need to read.

{
"BLD_BRH" : "****",
"RLS_STR" : "****",
"RLS_DFT" : [
[

],

],
"RLS_FIXED" :"***",
}

Section
ClearErrors
Push $0
nsJSON::Set /file "$EXEDIR\eg.json"

nsJSON::Get "RLS_STR" /end
Pop $0
MessageBox mb_ok $0
SectionEnd

it shows blank
shekara is offline   Reply With Quote
Old 11th October 2021, 18:29   #7
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
trailing commas are not allowed in JSON

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th October 2021, 19:05   #8
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
even without that, no difference. it is the same blank message
shekara is offline   Reply With Quote
Old 11th October 2021, 21:58   #9
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,418
There is known bug in this plug-in, it does not support empty arrays.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 12th October 2021, 12:32   #10
shekara
Junior Member
 
Join Date: Oct 2020
Posts: 33
my actual file is not empty... it looks like i have to use file and string instructions
shekara is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump