[erlang-questions] json to map

Richard A. O'Keefe ok@REDACTED
Mon Aug 31 06:25:17 CEST 2015


Specifically concerning the parsing of JSON,
actual numbers for my json.erl.

% SIZE       Lines Functions  clauses
% entry       5    1           1
% tokenising 77    6          29 (or 36, if you count 'case')
% parsing    28    3           6  (or 12, if you count 'case')
% utility     4    1           2
% TOTAL     114   11          38 (or 51, if you count 'case')

It was amusing that *parsing* JSON required just 3 functions
(parse any JSON value, parse body of non-empty array, parse
body of non-empty object).  It was interesting to see where
the difficulty was:  numbers (four functions) and strings
(handling backslash escapes).  Strings can appear in two places
in the JSON grammar, so having them recognised once in the
tokeniser avoids duplication in the parser.





More information about the erlang-questions mailing list