No Spaces on JSON.Decode

Post Reply
Wackedout
Posts: 3
Joined: Monday 01st October 2018 1:31pm

No Spaces on JSON.Decode

Post by Wackedout » Monday 01st October 2018 1:36pm

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: 205
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: No Spaces on JSON.Decode

Post by cogier » Monday 01st October 2018 3:46pm

Hi Wackout and welcome to the forum.

Have a look at the attached code.
Image
Attachments
GUITest.tar.gz
(12.85 KiB) Downloaded 21 times

Wackedout
Posts: 3
Joined: Monday 01st October 2018 1:31pm

Re: No Spaces on JSON.Decode

Post by Wackedout » Monday 01st October 2018 4:33pm

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 01st October 2018 1:31pm

Re: No Spaces on JSON.Decode

Post by Wackedout » Monday 01st October 2018 4:41pm

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

Thanks for the help! :D

grayghost4
Posts: 13
Joined: Wednesday 05th December 2018 5:00am

Re: No Spaces on JSON.Decode

Post by grayghost4 » Wednesday 05th December 2018 5:09am

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: 173
Joined: Wednesday 21st September 2016 1:19pm
Location: Norway

Re: No Spaces on JSON.Decode

Post by jornmo » Thursday 06th December 2018 7:52pm


Post Reply