[erlang-questions] json to map

Tony Rogvall tony@REDACTED
Tue Aug 25 15:21:05 CEST 2015


Or even

replace:
{ with #{
: with =>

and add the final dot.

:-)

/Tony


> On 25 aug 2015, at 14:21, Bengt Kleberg <bengt.kleberg@REDACTED> 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": "foo@REDACTED",
>>        "scope": ["admin", "user"]
>>    },
>>    "bar": {
>>        "id": 2,
>>        "username": "Bar Head",
>>        "first": "Bar",
>>        "last": "Head",
>>        "password": "bar",
>>        "email": "bar@REDACTED",
>>        "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
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150825/70731e2b/attachment.bin>


More information about the erlang-questions mailing list