No Spaces on JSON.Decode

Post your Gambas programming questions here.
Post Reply
Wackedout
Posts: 3
Joined: Monday 1st October 2018 1:31pm

No Spaces on JSON.Decode

Post by Wackedout »

When I get data using JSON.Decode the strings I have come out with no spaces in them...

i.e.

{
"Foo" : "Bar Bar Foo"
}

When I get the data for "Foo" it comes up as...
"BarBarFoo" instead of "Bar Bar Foo"

So am I forgetting something.
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: No Spaces on JSON.Decode

Post by cogier »

Hi Wackout and welcome to the forum.

Have a look at the attached code.
Image
Attachments
GUITest.tar.gz
(12.85 KiB) Downloaded 465 times
Wackedout
Posts: 3
Joined: Monday 1st October 2018 1:31pm

Re: No Spaces on JSON.Decode

Post by Wackedout »

Thanks for the welcome...

Ok I found out it was before the JSON.Decode, it seems to be
      FileIn = Open Filename For Input
        While Not Eof(FileIn)
          Input #FileIn, FileLine
          FileData = FileData & FileLine
        Wend
      Close FileIn
The "FileLine" var has no spaces. am I doing something wrong with the "Input" statement?
Wackedout
Posts: 3
Joined: Monday 1st October 2018 1:31pm

Re: No Spaces on JSON.Decode

Post by Wackedout »

OK I am an idiot (I guess) using "Line Input" instead of "Input" seems to fix it.

Thanks for the help! :D
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: No Spaces on JSON.Decode

Post by grayghost4 »

I am also working with json and havine trouble indexing a collection.


listofdata = JSON.Decode(File.Load("~/airplane files/Conscendo S2.srm"))
myindex = "data" & "," & "autopilot" & "," & "altHoldRate"
Print listofdata.count
Print listofdata.Length

Print listofdata[myindex]

End

what am I doing wrong
User avatar
jornmo
Site Admin
Posts: 224
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: No Spaces on JSON.Decode

Post by jornmo »

Post Reply