Page 1 of 1

No Spaces on JSON.Decode

Posted: Monday 1st October 2018 1:36pm
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.

Re: No Spaces on JSON.Decode

Posted: Monday 1st October 2018 3:46pm
by cogier
Hi Wackout and welcome to the forum.

Have a look at the attached code.
Image

Re: No Spaces on JSON.Decode

Posted: Monday 1st October 2018 4:33pm
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?

Re: No Spaces on JSON.Decode

Posted: Monday 1st October 2018 4:41pm
by Wackedout
OK I am an idiot (I guess) using "Line Input" instead of "Input" seems to fix it.

Thanks for the help! :D

Re: No Spaces on JSON.Decode

Posted: Wednesday 5th December 2018 5:09am
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

Re: No Spaces on JSON.Decode

Posted: Thursday 6th December 2018 7:52pm
by jornmo