[erlang-questions] json to map

Garrett Smith <>
Tue Aug 25 14:45:59 CEST 2015


Doesn't seem very challenging :)

But that's a valid point - a good programmer cheats!

Another cheat would be to use a JSON parsing library. Again not
particularly challenging, but it does send you down the road of "find
an existing solution to a problem, rather than roll your own".

For serious fun, write a parser! You could roll your own, or again
cheat by using Erlang's pretty darn good yecc module:

http://erlang.org/doc/man/yecc.html

On Tue, Aug 25, 2015 at 7:21 AM, Bengt Kleberg
<> wrote:
> Greetings,
>
> If you replace all
> :
> with
> ,
>
> and add a final
> .
>
> you can use file:consult/1 to read the file directly.
>
>
> bengt
>
>
> On 08/25/2015 02:16 PM, Roelof Wobben wrote:
>>
>> Hello,
>>
>> As a challenge I need to convert a json file to a erlang map.
>>
>> So I have this file :
>>
>> {
>>     "foo": {
>>         "id": 1,
>>         "username": "Foo Foo",
>>         "first": "Foo",
>>         "last": "Foo",
>>         "password": "foo",
>>         "email": "",
>>         "scope": ["admin", "user"]
>>     },
>>     "bar": {
>>         "id": 2,
>>         "username": "Bar Head",
>>         "first": "Bar",
>>         "last": "Head",
>>         "password": "bar",
>>         "email": "",
>>         "scope": ["user"]
>>     }
>> }
>>
>>
>> as far as I can see it's a tuple of tuples.
>> What are the steps to convert it.
>>
>> I do not need the code just some steps which point me to the right
>> direction.
>>
>> Roelof
>>
>>
>> ---
>> Dit e-mailbericht is gecontroleerd op virussen met Avast
>> antivirussoftware.
>> https://www.avast.com/antivirus
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions


More information about the erlang-questions mailing list