gpt4 book ai didi

ios - 如何在 iOS 中将数组作为参数发送给 json 服务

转载 作者:行者123 更新时间:2023-11-29 03:53:08 26 4
gpt4 key购买 nike

我正在使用基于 iPhone JSON Web 服务的应用程序。我需要将输入参数作为数组传递到 JSON Web 服务,我该如何执行此操作?

数组包含 12 个元素。这里提供 sample 服务...该服务的输入参数:dev_id = 1;dev_name= josh 和数组项 (projectslist,companyidentifier)

http://www.jyoshna.com/api/developer.php?dev_id=1&dev_name=josh&(Here我需要传递数组元素)

谁能帮助我们如何将数组作为输入参数传递给 json 服务?

最佳答案

首先你必须将数组转换为 JSON 字符串

NSString *requestString=[jsonParser stringWithObject:array];

将字符串转换为数据

NSData *data=[requestString dataUsingEncoding:NSUTF8StringEncoding];

将该数据设置为请求正文

[request setHTTPBody:data];

关于ios - 如何在 iOS 中将数组作为参数发送给 json 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16832016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com