【问题标题】:Compress/Minify a JSONObject before sending it over Http to Angular在通过 Http 将其发送到 Angular 之前压缩/缩小 JSONObject
【发布时间】:2018-05-31 15:27:20
【问题描述】:

有没有办法缩小get请求产生的json?我使用 .Net Core 作为后端,使用 Angular2 作为客户端,由于 Json 的大小,我的应用程序中的数据加载速度非常缓慢。我真的很感激任何建议。谢谢 !

【问题讨论】:

    标签: .net json angular minify


    【解决方案1】:

    您是否在使用 JSON 库 NewtonSoft?如果是这样,您应该能够使用格式:

        JObject obj = JObject.FromObject(new
        {
            typ = "photos"
        });
    
        return obj.ToString(Formatting.None);
    

    来源:Generate JSON object with NewtonSoft in a single line

    【讨论】:

    • Json 已经被格式化,所以它看起来没有空格,我认为有一种方法可以减小它的大小..:)
    • 您能否提供一些您期望的 JSON 输入和输出示例?
    猜你喜欢
    • 2012-07-09
    • 2017-05-17
    • 2020-02-25
    • 2017-02-26
    • 2019-06-13
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 2019-02-09
    相关资源
    最近更新 更多