JSON to XML: keys like `@type`, `$ref` or `bad key` turn into `<item>`
メンテナーはふだん 1 日以内に返信
@AyanZahid-Code がすでに取り組んでいます。
2026年10月20日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- json, typescript, xml
- 領域
- tooling
調査の方向性
Start with sanitizeTag and its callers in lib/json-utils.ts, then extend the toXML tests beginning at line 113 in lib/__tests__/json-utils.test.ts. Implement the specified ASCII tag-name rules and verify scalar keys, arrays, empty keys, Unicode, and unchanged valid names without adding an XML parser. Run npm run lint, npm run test, and npm run build; all should pass. Note that linked pull requests 216 and 217 are closed and unmerged, so confirm the issue remains unclaimed before starting.
索引モデルが issue の本文から書いたものです。
説明
The JSON formatter's XML conversion (toXML in lib/json-utils.ts) writes each key as a tag name. When a key isn't a valid XML name, sanitizeTag (line 573) drops the whole key and writes item instead:
{"bad key": 1, "1x": 2, "@type": "Person", "$ref": "#/a"}
gives
<root>
<item>1</item>
<item>2</item>
<item>Person</item>
<item>#/a</item>
</root>
so there's no way to tell which value was which. It happens to keys with a space or a leading digit, and to the @ and $ keys that JSON-LD (@context, @type, @id) and JSON Schema ($schema, $ref) use all the time. An array under such a key loses its name too: {"my tags": ["a", "b"]} gives two <itemItem> elements.
What to do
Keep the key and change only what XML doesn't allow:
- replace every character that isn't an ASCII letter, digit,
_,-or.with_ - put
_in front if the result starts with a digit,-or. - an empty key stays
item
So bad key becomes bad_key, 1x becomes _1x, @type becomes _type, $ref becomes _ref and a:b becomes a_b. Keys that are fine today, like first-name, user.id and _id, don't change.
Stay with ASCII, even though XML allows many other letters in names. Parsers don't agree on which ones (Python's built-in parser rejects some that libxml2 accepts), and ASCII names work in all of them. So café becomes caf_. Today it becomes item.
Where to look
lib/json-utils.ts:sanitizeTag(line 573).toXMLuses it for keys (line 609), array items (line 591) and the root element (line 615), so array items follow the fixed name without extra work:{"my tags": ["a", "b"]}should give two<my_tag>elements.lib/__tests__/json-utils.test.ts: thetoXMLtests start at line 113
Acceptance criteria
-
bad key,1x,@type,$ref,a:band-agive<bad_key>,<_1x>,<_type>,<_ref>,<a_b>and<_-a> -
first-name,user.idand_iddon't change, an empty key gives<item>, andcafégives<caf_> -
{"my tags": ["a", "b"]}gives two<my_tag>elements - Tests check the output text for each case above (please don't add an XML parser as a dependency)
-
npm run lint,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #214 in the description.
- 主要言語
- TypeScript
- スター
- 1
- フォーク
- 9
- 平均マージ
- 7時間 34分
- マージ済み PR(30日)
- 146
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
codercops/toolbelt のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Cron explainer says "on weekdays" for `0 0 1-31 * 1-5`, but the next runs include weekends対応中かも @Saifjafri212213 が今日担当しました。 オープンbug hacktoberfest help wanted
codercops/toolbelt#329 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
UUID generator's v7 batch comes out in random order instead of time order対応中かも @omisha123 が今日担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#316 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Invoice generator shows a subtotal of -$0.00 when the line items cancel out対応中かも @shresthgoel77-png が今日担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#315 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
JSON formatter's "Did you mean" hint reads inside strings, so a missing comma near a URL says to remove comments対応中かも @kachamsiddarth が今日担当しました。 オープンbug good first issue hacktoberfest
codercops/toolbelt#314 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
codercops/toolbelt の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
lyswhut/lx-music-desktop#3026 ·
-
area: ci type: test
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
schlessera/brain-kit#2769 ·
メンテナーはふだん 1 日以内に返信
-
Read a vector index's quantization back on Neo4j 2026.10, which reports vector.quantization.typeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
liberation-data/drivine#231 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
alveusgg/alveusgg#2502 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信