账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    JSON 数据拆分
    18
    0

    这是在数据提交时遇到的问题。

    我准备的数据结构是这样的:

        {
            "path": "test",
            "clients": [
                {
                    "client": "1.2.2.2;1.1.1.1",
                    "Access_Type": 2,
                    "name": "test_01"
                },
                {
                    "client": "1.2.2.4;1.1.1.4",
                    "Access_Type": 1,
                    "name": "test_02"
                },
                {
                    "client": "1.3.3.3",
                    "Access_Type": 1,
                    "name": "test_03"
                }
            ]
        }

    然而我在提交时需要的数据结构,却是这样的:

        {
            "path": "test",
            "clients": [
                {
                    "client": "1.2.2.2",
                    "Access_Type": 2,
                    "name": "test_01"
                },
                {
                    "client": "1.1.1.1",
                    "Access_Type": 2,
                    "name": "test_01"
                },
                {
                    "client": "1.2.2.4",
                    "Access_Type": 1,
                    "name": "test_02"
                },
                {
                    "client": "1.1.1.4",
                    "Access_Type": 1,
                    "name": "test_02"
                },
                {
                    "client": "1.3.3.3",
                    "Access_Type": 1,
                    "name": "test_03"
                }
            ]
        }

    注:client对应的字段,如果是多条并以“;”分隔,则做拆分处理,单条则不处理。

    那么如何将数据修改为提交需要的结构?
    而对于这种JSON数据结构的拆分,大家有什么解决方案,希望指教一下!

    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    • 李豫 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部