ruby-on-rails - Rails+Mongodb 使用 Swift 的反斜杠在 json 中获取对象
问题描述
我正在尝试从 swift 向 Rails+Mongodb 发送一个 json。我有一个带有字符串、整数和 2 个对象的 json。此对象 Fabrics 和 Palettes 嵌入在 WardrobeItem 中。
从 swift 我发送 Fabrics and Palettes 正确,没有反斜杠。
let jsonPalettes = try! JSONEncoder().encode(itemsWardrobe[0].palettes)
let jsonPString = String(data: jsonPalettes, encoding: .utf8)
let definitePalettes = jsonPString!.replacingOccurrences(of: "\\", with: "")
我的参数许可是
params.require(:wardrobe_items).permit(:name, :body_pos, :pattern, :season, :style, :clo_value, :layer, :last_worn_date, :washing, :wardrobe_id, :category_id, :events_id => [], :subcategory_ids => [], palettes: [:id, :name_color, :image_url, :color_palette_square], fabrics: [:id, :name])
我如何解决它?
解决方案
推荐阅读
- javascript - NodeJS - 从请求标头全局存储值
- python - Python - 如何使用 asyncio 使任务异步运行
- python - 将列添加到在 for 循环中创建的全局变量
- sql - 在后端保存待办事项列表项
- python - ValueError:检查输入时出错:预期 dense_151_input 具有 3 个维度,但得到了形状为 (2, 2100) 的数组
- laravel - 通知未广播到控制台?
- java - 在Java的循环中使用数组写入文件
- ios - 充当后台运行的 BLE 外围设备的 iOS 应用程序能否被来自 BLE 中心的连接请求唤醒?
- vb.net - 扩展方法不适用于 List(Of KeyValuePair(Of String, String))
- angular - 尝试订阅 MQTT 主题的问题 - Angular 5