嗨,用 mochijson2 解码 JSON 后,我得到了这个结果(示例结果)
{struct,
[{<<"query">>,
{struct,
[{<<"count">>,4},
{<<"created">>,<<"2013-11-08T18:33:07Z">>},
{<<"lang">>,<<"en-US">>},
{<<"results">>,
{struct,
[{<<"quote">>,
[{struct,
[{<<"symbol">>,<<"YHOO">>},
{<<"Ask">>,<<"32.99">>},
{<<"AverageDailyVolu"...>>,<<"18383000">>},
{<<"Bid">>,<<"32.98">>},
{<<"AskRealt"...>>,<<"32.9"...>>},
{<<"BidR"...>>,<<...>>},
{<<...>>,...},
{...}|...]},
我现在正试图从变量“符号”、“询问”等中获取信息。但我不知道如何获取它们。我尝试使用 proplists 来做这件事,这就是我得到的结果:
{struct, JsonData} = Struct,
{struct, Ask} = proplists:get_value(<<"Ask">>, JsonData),
Key = proplists:get_value(<<"Ask">>, Ask),
Key.
感谢@legoscia 的帮助