1

I am trying to decode json data in yaws, getting an error which is not clear to identify the issue. The Json data is

{
  "airport": [
    {"airport": "MAA"},
    {"city": "Chennai"},
    {"country": "India"},
    {"name": "Anna International Airport"}
  ]
}

The command i am using is

{ok, Json, _} = rfc4627:decode(Arg#arg.clidata).

The error is

Exception: undef Req: {http_request,'POST',{abs_path,"/sample/rest.yaws"},{1,1}} Stack: [{rfc4627,decode, [<<"{\n \"airport\": [\n {\"airport\": \"MAA\"},\n {\"city\": \"Chennai\"},\n {\"country\": \"India\"},\n {\"name\": \"Anna International Airport\"}\n ]\n}">>], []},

Rajan R.G
  • 825
  • 1
  • 7
  • 10
  • You will have to give more information. The error you see does not look like it is directly tied to the problem you are seing. – I GIVE CRAP ANSWERS Apr 28 '14 at 09:58
  • This is the code https://gist.github.com/rgrajan/11204417, i am trying REST in yaws. Then i pass the JSON using Chrome-Advanced REST client to test the services. – Rajan R.G Apr 28 '14 at 10:26
  • The requested data as per line# 56 prints `Request Data <<"{\n \"airport\": [\n {\"airport\": \"MAA\"},\n {\"city\": \"Chennai\"},\n {\"country\": \"India\"},\n {\"name\": \"Anna International Airport\"}\n ]\n}">>:` in the yaws console. I guess the issue is because of the special characters `<<` and `>>`. This is automatically formatted. – Rajan R.G Apr 28 '14 at 12:25
  • @RajanR.G - the << and >> characters merely indicate a binary object in erlang. They would not – Soup d'Campbells May 14 '14 at 19:17

1 Answers1

1

You're getting an undef exception, indicating that you're calling an undefined function. The error shows the stack, and at the top of the stack is the rfc4627:decode/1 function; that's the one that's undefined.

My guess is that your load path does not include the directory where you've stored the compiled rfc4627 module. You can add that directory to the Yaws load path by modifying your yaws.conf file and adding something like the following to the global config section (near the top):

ebin_dir = /path/to/where/rfc4627/is/stored

Note that you're allowed to have multiple ebin_dir settings; each is added to the load path.

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46