Hi, So I'm trying to decode JSON from a TCP connection.. What method are 
people using to read the JSON?

Server code sending json.

server = listen(8080)
while true
  conn = accept(server)
  @async begin
    try
      while true
        write(conn, "Hello Client!\n")
        line = readline(conn)
        # a sample JSON document
        json = "\n{'json':'hello'}\n\n"
        write(conn, json)
      end
    catch err
      print $err
    end
  end
end

Client side:

try
client = connect(8080)
print(readline(client))
while true
write(client, "Send me JSON\n")
print(readline(JSON.parse(client)))
end

catch err
  print("connection ended with error $err")
end

This gives me the following error:    ErrorException("Missing opening 
string char\nLine: 0\nAround: ...{'json':'hello'}...\n            ^\n")

I'm not sure I understand where the \n character should be placed.

Reply via email to