Permalink
Browse files

Put back filter_to_json:to_json/2, which had been mistakenly removed …

…in a previous commit
  • Loading branch information...
1 parent fc99ce2 commit 041b43522c759f46ab8fb2c428ab1cc8be903c4e @fcardinaux committed Feb 28, 2012
Showing with 13 additions and 1 deletion.
  1. +13 −1 modules/mod_base/filters/filter_to_json.erl
@@ -19,14 +19,26 @@
%% Modified by François Cardinaux in order to convert UTF8 strings correctly.
%% Usage:
%% * If the input value contains strings of UTF-8-encoded characters:
+%% {{ value|to_json }}
+%% or
%% {{ value|to_json:"utf-8" }}
%% * If the input value contains strings of ISO 8859-1 (= Latin-1) characters:
%% {{ value|to_json:"latin-1" }}
%% Note that these variants only concern the strings in the input term.
%% The output will always contain utf-8-encoded strings.
-module(filter_to_json).
--export([to_json/3]).
+-export([to_json/2, to_json/3]).
+
+%% @doc Convert an Erlang list or tuple to JSON
+%% This function assumes that all strings of the input term are made of utf-8-encoded characters.
+%% @spec to_json(ErlangTerm, Context) -> Json
+%% Where:
+%% * ErlangTerm = list() | tuple()
+%% * Context = Zotonic context record
+%% * Json = the JSON content
+to_json(Value, Context) ->
+ to_json(Value, "utf-8", Context).
%% @doc Convert an Erlang list or tuple to JSON
%% This function assumes that the all strings of the input term have the same

0 comments on commit 041b435

Please sign in to comment.