Maps - crownedgrouse/argos GitHub Wiki

Maps

Keys and values

Keys are atoms by default, but can be tuned with {binary, ...}. If key cannot be converted to atom, an error invalid_atom_key is raised.

Values are strings by default but can be tuned with {binary, ...} too.

Decoding

JSON decoding to Erlang map need the option {mode, map}, {mode, maps} or {mode, m}.

1> argos:decode_file("priv/ex1.json",[{mode, map}]).
#{glossary =>
      #{title => "example glossary",
        'GlossDiv' =>
            #{title => "S",
              'GlossList' =>
                  #{'GlossEntry' =>
                        #{'ID' => "SGML",'SortAs' => "SGML",
                          'GlossTerm' => "Standard Generalized Markup Language",
                          'Acronym' => "SGML",'Abbrev' => "ISO 8879:1986",
                          'GlossDef' =>
                              #{para =>
                                    "A meta-markup language, used to create markup languages such as DocBook.",
                                'GlossSeeAlso' => ["GML","XML"]},
                          'GlossSee' => "markup"}}}}}