如何从动态JSON文件中获取数据和键并以表格格式显示为HTML
**PS:这个JSON将是动态的,数据可能不会一直*相同。**例如:有时会有2组或3组数据,键和值会不同,等等……
我正在尝试从https://amp.gmail.dev/playground/public/ssr_amp_list文件中获取JSON
结果格式(key
-value
):
<div class="mySet">
<span class="myKey">id<span> - <span class="myValue">1<span>
<span class="myKey">img</span> - <span class="myValue">https://amp.dev/static/samples/img/product1_640x426.jpg</span>
<span class="myKey">name</span> - <span class="myValue">Apple</span>
<span class="myKey">price</span> - <span class="myValue">1.99</span>
<span class="myKey">stars</span> - <span class="myValue">★★</span>
<span class="myKey">attribution<span> - <span class="myValue">visualhunt</span>
<span class="myKey">url</span> - <span class="myValue">#</span>
<span class="myKey">color</span> - <span class="myValue">green</span>
<div>
<div class="mySet">
<span class="myKey">id</span> - <span class="myValue">1</span>
<span class="myKey">img</span> - <span class="myValue">https://amp.dev/static/samples/img/product1_640x426.jpg</span>
<span class="myKey">name</span> - <span class="myValue">Apple</span>
<span class="myKey">price</span> - <span class="myValue">1.99</span>
<span class="myKey">stars</span> - <span class="myValue">★★</span>
<span class="myKey">attribution</span> - <span class="myValue">visualhunt</span>
<span class="myKey">url</span> - <span class="myValue">#</span>
<span class="myKey">color</span> - <span class="myValue">green</span>
<div>
etc...
1条答案
按热度按时间aiqt4smr1#
您可以使用Foreach显示所有键和值,如下所示:
Array.Foreach((Value,index)=>{Enter code here index可以按值显示数组的all
enter code here
条目,可以显示value.name等所有值)