プロジェクト

全般

プロフィール

Vote #67869

完了

JSON API holds less information than XML API

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
REST API_32
対象バージョン:
開始日:
2010/08/13
期日:
進捗率:

0%

予定工数:
category_id:
32
version_id:
20
issue_org_id:
6136
author_id:
18999
assigned_to_id:
0
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Currently the JSON API provides less information than the XML API. E.g. custom fields (resolution) isn't accessible by the JSON API.

Example:
http://svn.jdownloader.org/issues/1531.json
http://svn.jdownloader.org/issues/1531.xml

(1.0.0.stable.3936)


journals

This appears to be happening because the issue show action has a custom view (show.builder.xml) that is including the issue's relations, custom fields, etc. whereas the JSON format uses default to_json method on the issue model which doesn't include those things.

I'm going to tackle this by moving the XML builder code into the issue model's to_xml method instead of a view file. Then I'll make the issue's to_json method just call the to_xml method and convert the XML to JSON so we only need to maintain the serialization code in one place.
--------------------------------------------------------------------------------
I think this patch addresses the issue. The changes are also available at http://github.com/asoltys/redmine/tree/issue_serialization
--------------------------------------------------------------------------------
This is a real problem with using the XML views. Instead of overriding @to_xml@, I'm wondering if there is a common method we can make so both XML and JSON formats are always the same. Example:

<pre><code class="ruby">
def to_xml
self.to_api_format(:xml)
end

def to_json
self.to_api_format(:json)
end

def to_api_format(renderer)
{
:id => self.id,
:subject => self.subject,
# ....
}
# ...
end
</code></pre>
--------------------------------------------------------------------------------
Fixed in r4458. xml and json responses now use the same template.
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,7158,Issues Custom fields not in json

Admin Redmine さんが3年以上前に更新

  • カテゴリREST API_32 にセット
  • 対象バージョン1.1.0_20 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0