繁体   English   中英

如何通过 jsonEncode http 帖子?

[英]how to pass jsonEncode http post?

我得到了所有参数 jsonEncode 然后我将通过 http 帖子。 我在下面通过源代码进行了解释。

 var abc =  jsonEncode({
        "requisitionID": "x",
        "RetailerTitle": "Faruqe Ahmed  Store",
        "RetailerAddress" : "Dhaka Nilkhet",
        "Market": "Nilkhet",
        "RetailerAreaType":"R",
        "RetailerType":"R",
        "RetailerProprieterName": "Faruqe Ahmed",
        "RetailerContactNumber": "01736611372",
        "Longitude": "Longitude",
        "Lattitude": "Lattitude",
        "Thana": {"ThanaID": "Shahbag"},
        "District": {"DistrictID": "Dhaka"},
        "EntryParameter": {"CompanyID": "x"},
        "EntryParameter": {"LocationID": "x"},
        "EntryParameter": {"MachineID": "x"},
        "EntryParameter": {"EntryBy": "D180064"},
        "EntryParameter": {"UpdateBy": "x"},
        "ImageFieldBanner": ""
      }),

但是当我从 print(abc.toString()) 获取字符串时。 然后我只有

{
        "requisitionID": "x",
        "RetailerTitle": "Faruqe Ahmed  Store",
        "RetailerAddress" : "Dhaka Nilkhet",
        "Market": "Nilkhet",
        "RetailerAreaType":"R",
        "RetailerType":"R",
        "RetailerProprieterName": "Faruqe Ahmed",
        "RetailerContactNumber": "01736611372",
        "Longitude": "Longitude",
        "Lattitude": "Lattitude",
        "Thana": {"ThanaID": "Shahbag"},
        "District": {"DistrictID": "Dhaka"},
        "EntryParameter": {"UpdateBy": "x"},
        "ImageFieldBanner": ""
      }

跳过

   "EntryParameter": {"CompanyID": "x"},
        "EntryParameter": {"LocationID": "x"},
        "EntryParameter": {"MachineID": "x"},
        "EntryParameter": {"EntryBy": "D180064"},

我需要

{
        "requisitionID": "x",
        "RetailerTitle": "Faruqe Ahmed  Store",
        "RetailerAddress" : "Dhaka Nilkhet",
        "Market": "Nilkhet",
        "RetailerAreaType":"R",
        "RetailerType":"R",
        "RetailerProprieterName": "Faruqe Ahmed",
        "RetailerContactNumber": "01736611372",
        "Longitude": "Longitude",
        "Lattitude": "Lattitude",
        "Thana": {"ThanaID": "Shahbag"},
        "District": {"DistrictID": "Dhaka"},
        "EntryParameter": {"CompanyID": "x"},
        "EntryParameter": {"LocationID": "x"},
        "EntryParameter": {"MachineID": "x"},
        "EntryParameter": {"EntryBy": "D180064"},
        "EntryParameter": {"UpdateBy": "x"},
        "ImageFieldBanner": ""
      }

您为 jsonEncode 方法提供的参数是 Map<String, String>,map 使用唯一键来访问其值。

您的 map 多次使用“EntryParameter”键,这会导致同一个值被多次覆盖,而只保留最后一个值。

为了解决这个问题,如果 output 结构很重要,您可能需要将键值对放在一个数组中并自己创建所需的 json 代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM