我正在尝试将自定义数组与render json的结果合并。
render json: @value, each_serializer: JsonApi::ValueSerializer
数组为a = [1,2,3]
。
使用此json的结果是否可以追加数组?
该数组将被构建为json
"a":{"1": "one","2":"two", "3": "three"}
通常,序列化器的json值为
'{"data":{"value_id":"1","attributes {{"id": "1","email":"tech@sample.com","access_locked":false},{"id": "2","email":"tech2@sample.com","access_locked":true}}}'
在将带有标准化值的“ a” json附加后的最终所需结果是
'{"data":{"value_id":"1","attributes {{"id": "1","email":"tech@sample.com","access_locked":false},{"id": "2","email":"tech2@sample.com","access_locked":true}}, "a":{"1": "one","2":"two", "3": "three"}}}'