YYModel icon indicating copy to clipboard operation
YYModel copied to clipboard

容器类转换中怎样处理多维数组的转换?

Open HecvStyle opened this issue 8 years ago • 8 comments

 "courseList": 
[
      [
        {
         "courseid":" xxxxxxxxxxxx",
          "grade": "三年级",
          "subjectName": "英语",
          "stage": "2班"
        },
        {
        "courseid":" xxxxxxxxxxxx",
          "grade": "",
          "subjectName": "",
          "stage": ""
        },
        {
        "courseid":" xxxxxxxxxxxx",
          "grade": "三年级",
          "subjectName": "英语",
          "stage": "2班"
        },
        {
        "courseid":" xxxxxxxxxxxx",
          "grade": "三年级",
          "subjectName": "英语",
          "stage": "2班"
        },
        {
        "courseid":" xxxxxxxxxxxx",
          "grade": "",
          "subjectName": "",
          "stage": ""
        },
        {
          "grade": "",
          "subjectName": "",
          "stage": ""
        },
        {
          "grade": "",
          "subjectName": "",
          "stage": ""
        }
      ]
]

HecvStyle avatar Apr 11 '16 04:04 HecvStyle

容器类中包含容器类,是无法隐射到model对象的,因为对象的属性,是和映射的key相关的,容器类中的容器类,根本没有映射对应的key。不知理解是否正确

HecvStyle avatar Apr 15 '16 01:04 HecvStyle

是的,key path 的语法只支持 dictionary。。

这中映射,可以在 modelCustomWillTransformFromDictionary 或者 modelCustomTransformFromDictionary 中额外处理一下。

ibireme avatar Apr 15 '16 02:04 ibireme

刚测试发现这个问题, 目前mantle和yymodel都不能自动处理,只有 MJExtention能处理到。希望 @ibireme 能改进这个功能

iwanglian avatar May 20 '16 04:05 iwanglian

http://chengway.in/mantle-chu-tan-xiu-gai-shi-qi-zhi-chi-ren-yi-qian-tao-array/ 这里搜索到修改mantle的方法

iwanglian avatar May 20 '16 04:05 iwanglian

为什么不使用嵌套model呢?每个点是一个model,每个xyz轴也是一个model

YasinZhou avatar Jun 07 '16 03:06 YasinZhou

modelCustomTransformFromDictionary 方法可以解决,稍微麻烦了一点,期待大神改进+1

Phelthas avatar Jun 15 '16 12:06 Phelthas

我提交了一个pullrequest,实现多维数组的转化,不会影响效率

ZoMinster avatar Jan 22 '18 07:01 ZoMinster

刚测试发现这个问题, 目前mantle和yymodel都不能自动处理,只有 MJExtention能处理到。希望 @ibireme 能改进这个功能

mj怎么去处理这个情况

Liyongcong avatar Oct 14 '20 10:10 Liyongcong