I just need two fields in this JSON----Note and Total,I want to display the data in the example below.
If you want to fetch specific field from Json, I suggest you could use JSON.parse.
I make a demo,you could refer to it:
<script src="Scripts/jquery-3.3.1.min.js"></script>
<script>
var txt = '{"Total":10,"NumPerPage":50,"currentPage":1,"Result":[{"GoodsId":"00000000-0000-0000-0000-000000000000","GoodsNum":null,"GoodsName":null,"Author":null,"Supplier":null,"TypeId":0,"TypeList":null,"TypeName":null,"Page":0,"Price":null,"StatusId":0,"StatusList":null,"StatusName":null,"Owner":"00000000-0000-0000-0000-000000000000","OwnerName":null,"CreatedOn":"0001-01-01T00:00:00","Total":5,"Id":0,"Note":"Jim"},{"GoodsId":"00000000-0000-0000-0000-000000000000","GoodsNum":null,"GoodsName":null,"Author":null,"Supplier":null,"TypeId":0,"TypeList":null,"TypeName":null,"Page":0,"Price":null,"StatusId":0,"StatusList":null,"StatusName":null,"Owner":"00000000-0000-0000-0000-000000000000","OwnerName":null,"CreatedOn":"0001-01-01T00:00:00","Total":4,"Id":0,"Note":"Damon"}]}';
var obj = JSON.parse(txt);
$.each(obj.Result, function (index, value)
{
console.log("Total:" + value.Total + " Note:" + value.Note); });
</script>
How it works:
Best Regards.
Yuki Tao
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Contributor
3710 Points
1431 Posts
Re: Display JSON data from Controller to View using the ECHARTS
Aug 29, 2018 10:10 AM|Yuki Tao|LINK
Hi Klaus Shen,
If you want to fetch specific field from Json, I suggest you could use JSON.parse.
I make a demo,you could refer to it:
How it works:
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.