zoukankan      html  css  js  c++  java
  • JSON parse \n bug All In One

    JSON parse \n bug All In One

    const obj = {str: "\n\ntext"};
    // {str: '\n\ntext'}
    
    const str = JSON.stringify(obj);
    // '{"str":"\\n\\ntext"}'
    
    const result = JSON.parse(str);
    // {str: '\n\ntext'}
    
    

    处理 \n bug

    接口数据问题

    material_content: "{\"pc\":[],\"mobile\":[{\"id\":\"261916\",\"type\":\"simple-text\",\"name\":\"简单文本\",\"preview\":\"/assets/add-simple-text.jpg\",\"classNames\":[],\"props\":{\"width\":375,\"height\":600,\"left\":0,\"top\":0,\"zIndex\":100,\"aspectRatio\":false,\"text\":\"\n\n\n\nworjd\",\"font\":{\"color\":\"#C53636\",\"family\":\"\",\"size\":\"58\",\"bold\":true},\"gradient\":false,\"textAlign\":\"center\",\"letterSpacing\":0,\"lineHeight\":1}}]}"
    
    
    {
      "name": "wenbenjkuang012",
      "game_id": 10043,
      "region_id": null,
      "thum_url": "https://adpage.lilithcdn.com/online_dragonfly/1638253043_wenbenjkuang012_1638253043.0.jpeg",
      "material_content": "{\"pc\":[],\"mobile\":[{\"id\":\"261916\",\"type\":\"simple-text\",\"name\":\"简单文本\",\"preview\":\"/assets/add-simple-text.jpg\",\"classNames\":[],\"props\":{\"width\":375,\"height\":600,\"left\":0,\"top\":0,\"zIndex\":100,\"aspectRatio\":false,\"text\":\"\n\n\n\nworjd\",\"font\":{\"color\":\"#C53636\",\"family\":\"\",\"size\":\"58\",\"bold\":true},\"gradient\":false,\"textAlign\":\"center\",\"letterSpacing\":0,\"lineHeight\":1}}]}",
      "is_used": 0,
      "id": 95,
      "user_name": "Eric",
      "note": "wenbenjkuang012"
    }
    
    

    OK

    material_content: "{\"pc\":[],\"mobile\":[{\"id\":\"261916\",\"type\":\"simple-text\",\"name\":\"简单文本\",\"preview\":\"/assets/add-simple-text.jpg\",\"classNames\":[],\"props\":{\"width\":375,\"height\":600,\"left\":0,\"top\":0,\"zIndex\":100,\"aspectRatio\":false,\"text\":\"\\n\\n\\n\\nworjd\",\"font\":{\"color\":\"#C53636\",\"family\":\"\",\"size\":\"58\",\"bold\":true},\"gradient\":false,\"textAlign\":\"center\",\"letterSpacing\":0,\"lineHeight\":1}}]}"
    
    

    refs



    ©xgqfrms 2012-2020

    www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

    原创文章,版权所有©️xgqfrms, 禁止转载 ️,侵权必究⚠️!


    xgqfrms
  • 相关阅读:
    项目中的注意事项
    复合查询
    树型控件的处理(完整版)
    图的存储结构(邻接矩阵)
    图的定义与术语2 数据结构和算法55
    图的存储结构(邻接矩阵)
    赫夫曼编码 数据结构和算法52
    赫夫曼编码 数据结构和算法52
    图的存储结构(邻接矩阵)
    图的定义与术语 数据结构和算法54
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/15627157.html
Copyright © 2011-2022 走看看