変換できないとき
- 確かめる
- 直す
「変換できませんでした。JSONの書き方などを確かめてください。」と表示されて、先に進めない。CSVとJSONを相互変換する で変換できないときの、原因と直し方をまとめます。
まず確認すること
- 変換の向きは合っているか:CSVを貼り付けているのに、「JSON → CSV」になっていないか。
- 区切り文字は合っているか:データに合わせて、選び直す。
- データが空ではないか:貼り付けが、できているか。
- JSONの書き方は正しいか:かっこの数や、カンマの位置。
手順(直す)
- 「変換の向き」を、確認します。
- 「変換前」の内容を見直します。
- 区切り文字を、データに合わせます。
- もう一度「変換する」を押します。
JSONでよくある書き方の誤り
- 最後の項目の後ろに、余分なカンマがある:{"a": 1, "b": 2,} のように。
- シングルクォーテーションを使っている:JSONでは、ダブルクォーテーション(")が必要。
- 項目名が、引用符で囲まれていない:項目名は、ダブルクォーテーションで囲む。
- かっこの閉じ忘れ:{ と }、[ と ] の数が合っていない。
- コメントが入っている:JSONには、コメントを書けない。
CSVでよくある問題
- 区切り文字が違う:カンマのつもりが、タブだった。
- ダブルクォーテーションの閉じ忘れ:項目を囲む引用符が、対応していない。
- 改行を含む項目:引用符で囲まれていないと、行がずれる。
JSONの誤りを探すコツ
- 短いデータで、試してみる
- 少しずつ、貼り付けて確認する
- テキストエディタで、かっこの対応を確認する
- 別のJSON整形ツールで、チェックする
向いている対処
データの一部だけを貼り付けて、変換できるか確かめると、どこが問題か分かります。
例
APIの結果を貼り付けたら、エラーになった。見ると、末尾に説明文が混ざっていた。JSONの部分だけを貼り付け直して、変換できた。
つまずきやすい点
- コピーしたとき、一部が欠けた:全体を選んで、コピーし直す。
- 全角の記号が混ざっている:全角のかっこや引用符は、JSONでは使えない。
- 文字コードの問題:貼り付け元を確認する。
よくある質問
エラーの場所を教えてくれますか?
このツールは、エラーの行を表示しません。上のポイントを、順に確認してください。
まとめ
向き、区切り文字、JSONの書き方を順に確認。短いデータで、試すのがコツです。
CSVとJSONを相互変換するを使う(無料)あわせて使えるツール
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
- ファイルをZIPにまとめる:複数のファイルを、1つのZIPにまとめます。
- 文字数カウント(エントリーシート・レポート用):文章の文字数・行数・原稿用紙の枚数などを数えます。
同じツールの、ほかの解説
When the Conversion Fails
- Check
- Fix
"Could not convert. Check the JSON syntax and so on." is shown and you can't proceed. Here are causes and fixes for when Convert CSV and JSON cannot convert.
What to check first
- Is the direction right?: Are you pasting CSV while it is set to "JSON → CSV"?
- Is the delimiter right?: choose again to match the data.
- Is the data empty?: whether pasting worked.
- Is the JSON syntax correct?: the number of brackets and placement of commas.
Steps (fixing)
- Check the "Direction".
- Review the content of "Before conversion".
- Match the delimiter to the data.
- Press "Convert" again.
Common JSON syntax mistakes
- An extra comma after the last item: like {"a": 1, "b": 2,}.
- Using single quotes: JSON requires double quotes (").
- Item names not enclosed in quotes: item names are enclosed in double quotes.
- Unclosed brackets: the numbers of { and }, [ and ] don't match.
- Comments included: JSON cannot have comments.
Common CSV problems
- Wrong delimiter: meant comma but it was tab.
- Unclosed double quotes: the quotes enclosing items don't pair up.
- Items containing line breaks: without quotes around them, rows shift.
Tips for finding JSON mistakes
- Try with short data
- Paste a little at a time and check
- Check bracket pairing in a text editor
- Check with another JSON formatting tool
A useful approach
Pasting just part of the data and seeing whether it converts shows where the problem lies.
Example
Pasting an API result gave an error. Looking, explanatory text was mixed in at the end. Pasting only the JSON part again, it converted.
Common stumbling blocks
- Part was missing when copied: select all and copy again.
- Full-width symbols mixed in: full-width brackets and quotes can't be used in JSON.
- Encoding problems: check the paste source.
Frequently asked questions
Does it tell me where the error is?
This tool does not show the error line. Check the points above in order.
Summary
Check the direction, delimiter and JSON syntax in turn. Trying with short data is the tip.
Use "Convert CSV and JSON" (free)Tools that go well with this
- Remove Duplicate Lines and Sort a List: Remove duplicate lines and sort them.
- Make a ZIP File: Pack several files into one ZIP.
- Character Counter (for Applications and Reports): Count characters, lines and manuscript sheets of your text.