diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index b0ab8947..95ada0bd 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -1,4 +1,5 @@ require 'uri' +require 'json' module Jekyll module Filters @@ -148,6 +149,15 @@ module Jekyll end end + # Convert the input into json string + # + # input - The Array or Hash to be converted + # + # Returns the converted json string + def jsonify(input) + input.to_json + end + private def time(input) case input diff --git a/site/docs/templates.md b/site/docs/templates.md index 8ecff675..0417f2ab 100644 --- a/site/docs/templates.md +++ b/site/docs/templates.md @@ -173,6 +173,17 @@ common tasks easier.
+Data To JSON
+Convert Hash or Array to JSON.
+
+ {% raw %}{{ site.data.projects | jsonify }}{% endraw %}
+