我正在使用gradereport_user_get_grades_table moodle mobile webservice,它以JSON格式检索数据

时间:2016-12-26 09:56:44

标签: angularjs json

我正在使用名为gradereport_user_get_grades_table的Web服务并从其他客户端执行它,它以JSON格式返回数据。我的问题是如何从以下JSON格式显示角度JS中的10.0等级内容值。

{
  "tables": [{
    "courseid": 8,
    "userid": 14,
    "userfullname": "bhavani Rayappanavar",
    "maxdepth": 2,
    "tabledata": [{
      "itemname": {
        "class": "level1 levelodd oddd1 b1b b1t column-itemname",
        "colspan": 7,
        "content": "CategoryPhysics",
        "celltype": "th",
        "id": "cat_8_14"
      },
      "leader": {
        "class": "level1 levelodd oddd1 b1t b2b b1l column-leader",
        "rowspan": 3
      }
    }, {
      "itemname": {
        "class": "level2 leveleven item b1b column-itemname",
        "colspan": 1,
        "content": "Quizquiz",
        "celltype": "th",
        "id": "row_164_14"
      },
      "weight": {
        "class": "level2 leveleven item b1b itemcenter  column-weight",
        "content": "100.00 %",
        "headers": "cat_8_14 row_164_14 weight"
      },
      "grade": {
        "class": "level2 leveleven item b1b itemcenter  column-grade",
        "content": "10.00",
        "headers": "cat_8_14 row_164_14 grade"
      },
      "range": {
        "class": "level2 leveleven item b1b itemcenter  column-range",
        "content": "0–10",
        "headers": "cat_8_14 row_164_14 range"
      },
      "percentage": {
        "class": "level2 leveleven item b1b itemcenter  column-percentage",
        "content": "100.00 %",
        "headers": "cat_8_14 row_164_14 percentage"
      },
      "feedback": {
        "class": "level2 leveleven item b1b feedbacktext column-feedback",
        "content": " ",
        "headers": "cat_8_14 row_164_14 feedback"
      },
      "contributiontocoursetotal": {
        "class": "level2 leveleven item b1b itemcenter  column-contributiontocoursetotal",
        "content": "100.00 %",
        "headers": "cat_8_14 row_164_14 contributiontocoursetotal"
      }
    }, {
      "itemname": {
        "class": "level1 levelodd oddd1 baggt b2b column-itemname",
        "colspan": 1,
        "content": "NaturalCourse total",
        "celltype": "th",
        "id": "row_103_14"
      },
      "weight": {
        "class": "level1 levelodd oddd1 baggt b2b itemcenter  column-weight",
        "content": "-",
        "headers": "cat_8_14 row_103_14 weight"
      },
      "grade": {
        "class": "level1 levelodd oddd1 baggt b2b itemcenter  column-grade",
        "content": "10.00",
        "headers": "cat_8_14 row_103_14 grade"
      },
      "range": {
        "class": "level1 levelodd oddd1 baggt b2b itemcenter  column-range",
        "content": "0–10",
        "headers": "cat_8_14 row_103_14 range"
      },
      "percentage": {
        "class": "level1 levelodd oddd1 baggt b2b itemcenter  column-percentage",
        "content": "100.00 %",
        "headers": "cat_8_14 row_103_14 percentage"
      },
      "feedback": {
        "class": "level1 levelodd oddd1 baggt b2b feedbacktext column-feedback",
        "content": " ",
        "headers": "cat_8_14 row_103_14 feedback"
      },
      "contributiontocoursetotal": {
        "class": "level1 levelodd oddd1 baggt b2b itemcenter  column-contributiontocoursetotal",
        "content": "-",
        "headers": "cat_8_14 row_103_14 contributiontocoursetotal"
      }
    }]
  }],
  "warnings": []
}

1 个答案:

答案 0 :(得分:0)

通过将json分配给$ scope变量并使用

获取,可以显示如下所示



using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Spire.Doc;
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Presentation;
using Spire.Xls;

namespace Merge_Office_Files_to_PDF
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    private void button1_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();

        ofd.Filter = "All files (*.docx, *.pdf, *.pptx, *.pdf)| *.docx; *.pdf; *.pptx; *.xlsx";

        ofd.Multiselect = true;

        if (DialogResult.OK == ofd.ShowDialog())
        {

            string[] files = ofd.FileNames;

            listBox1.Items.AddRange(files);
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {

        string ext = string.Empty;
        List<Stream> filesStreams = new List<Stream>();
        MemoryStream ms1 = new MemoryStream();
        MemoryStream ms2 = new MemoryStream();
        MemoryStream ms3 = new MemoryStream();
        foreach (object item in listBox1.Items)
        {
            ext = Path.GetExtension(item.ToString());
            switch (ext)
            {
                case ".docx":
                    Document doc = new Document(item.ToString());
                    doc.SaveToStream(ms1, Spire.Doc.FileFormat.PDF);
                    filesStreams.Add(ms1);

                    break;
                case ".pdf":
                    filesStreams.Add(File.OpenRead(item.ToString()));
                    break;
                case ".pptx":
                    Presentation ppt = new Presentation(item.ToString(), Spire.Presentation.FileFormat.Auto);
                    ppt.SaveToFile(ms2, Spire.Presentation.FileFormat.PDF);
                    filesStreams.Add(ms2);

                    break;
                case ".xlsx":
                    Workbook xls = new Workbook();
                    xls.LoadFromFile(item.ToString());
                    xls.SaveToStream(ms3, Spire.Xls.FileFormat.PDF);
                    filesStreams.Add(ms3);

                    break;
                default:
                    break;

            }
        }
        string outputFile = "result.pdf";
        PdfDocumentBase result = PdfDocument.MergeFiles(filesStreams.ToArray());
        result.Save(outputFile, Spire.Pdf.FileFormat.PDF);
        ms1.Close();
        ms2.Close();
        ms3.Close();            
    }
}
&#13;
&#13;
&#13;