Inline Json in Erlang

While I was writing about parse transforms for the ERTS book I needed an
example of a simple parse transform. So just for fun I came up with
a little syntax for writing Json structures in-line in Erlang.

With this parse transform you can write things like


-module(json_test).
-compile({parse_transform, json_parser}).
-export([test/1]).

test(V) ->
    <<{{
      "name"  : "Jack (\"Bee\") Nimble",
      "format": {
                  "type"      : "rect",
                  "widths"     : [1920,1600],
                  "height"    : (-1080),
                  "interlace" : false,
                  "frame rate": V
                }
     }}>>.

The code is available on my GitHub account:
https://github.com/happi/json-transform

This entry was posted in Development, Erlang and tagged , by happi. Bookmark the permalink.

About happi

I have been programming for fun since 1980, and for profit since 1989 when I started my first company. I have been working on native code compilation of Erlang, with the implementation of Scala, on virtual machines, and with internet scale online payment solutions. Currently I am writing a book on the Erlang Runtime System (ERTS).