获取Li3以将JSON结果作为对象数组返回,而不是对象的对象

获取Li3以将JSON结果作为对象数组返回,而不是对象的对象,json,lithium,Json,Lithium,我试图利用我的Li3应用程序的GET请求的JSON结果,但我希望结果是返回的JSON对象的数组,而不是JSON对象的对象 我的视图文件(index.html.php)中有以下代码: print($todos->to('json')) 这会导致每一行都成为一个JSON对象(好),但在一个超架构的JSON对象中 { "1": { "id": "1", "title": "One", "done": "0" }, "2": {

我试图利用我的Li3应用程序的GET请求的JSON结果,但我希望结果是返回的JSON对象的数组,而不是JSON对象的对象

我的视图文件(index.html.php)中有以下代码:
print($todos->to('json'))

这会导致每一行都成为一个JSON对象(好),但在一个超架构的JSON对象中

{
    "1": {
        "id": "1",
        "title": "One",
        "done": "0"
    },
    "2": {
        "id": "2",
        "title": "Two",
        "done": "0"
    },
    "3": {
        "id": "3",
        "title": "Three",
        "done": "0"
    },
    "4": {
        "id": "4",
        "title": "Four",
        "done": "0"
    }
}
我想得到:

[
    {
        "id": "1",
        "title": "One",
        "done": "0"
    },
    {
        "id": "2",
        "title": "Two",
        "done": "0"
    },
    {
        "id": "3",
        "title": "Three",
        "done": "0"
    },
    {
        "id": "4",
        "title": "Four",
        "done": "0"
    }
]
注意:我发现的commit“”中的情况是这样的(对象数组),但是在提交之后,结果是对象对象对象。

尝试
$todos->to('json',['index'=>false])
,或者,参考
媒体
类直接序列化json而不使用模板。

todos::all(['return'=>'array'))->to('json');
也适用于
记录集