Change single quotes->double quotes (which you need to escape in Julia).
from json.org:

A *value* can be a *string* in double quotes, or a *number*, or true or
> false or null, or an *object* or an *array*. These structures can be
> nested.
>



On Sun, Mar 23, 2014 at 5:37 PM, Collin Glass <collinglas...@gmail.com>wrote:

> 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