No Spaces on JSON.Decode

Post

Posted
Rating:
#1 (In Topic #192)
Trainee
 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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Wackout and welcome to the forum.

Have a look at the attached code.
<IMG src="http://www.cogier.com/gambas/Wackedout.jpg"> </IMG>

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#3
Trainee
Thanks for the welcome…

Ok I found out it was before the JSON.Decode, it seems to be

Code (gambas)

  1.       FileIn = Open Filename For Input
  2.         While Not Eof(FileIn)
  3.           Input #FileIn, FileLine
  4.           FileData = FileData & FileLine
  5.         Wend
  6.       Close FileIn

The "FileLine" var has no spaces. am I doing something wrong with the "Input" statement?
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
OK I am an idiot (I guess) using "Line Input" instead of "Input" seems to fix it.

Thanks for the help!  :D
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 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
Online now: No Back to the top

Post

Posted
Rating:
#6
Online now: No Back to the top
1 guest and 0 members have just viewed this.