~ubuntu-branches/ubuntu/saucy/rabbitmq-server/saucy

« back to all changes in this revision

Viewing changes to plugins-src/sockjs-erlang-wrapper/sockjs-erlang-git/src/sockjs_json.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2012-11-19 11:42:31 UTC
  • mfrom: (0.2.18) (0.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20121119114231-hvapkn4akng09etr
Tags: 3.0.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% ***** BEGIN LICENSE BLOCK *****
 
2
%% Copyright (c) 2011-2012 VMware, Inc.
 
3
%%
 
4
%% For the license see COPYING.
 
5
%% ***** END LICENSE BLOCK *****
 
6
 
 
7
-module(sockjs_json).
 
8
 
 
9
-export([encode/1, decode/1]).
 
10
 
 
11
%% --------------------------------------------------------------------------
 
12
 
 
13
%% -spec encode(any()) -> iodata().
 
14
encode(Thing) ->
 
15
    mochijson2_fork:encode(Thing).
 
16
 
 
17
%% -spec decode(iodata()) -> {ok, any()} | {error, any()}.
 
18
decode(Encoded) ->
 
19
    try mochijson2_fork:decode(Encoded) of
 
20
        V -> {ok, V}
 
21
    catch
 
22
        _:E -> {error, E}
 
23
    end.