# JsonError("expected value at line 1 column 2") | Import of .apkg file failed

**URL:** <https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355>\
**Category:** Development\
**Created:** [July 10, 2022, 12:38pm UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355 "2022-07-10T12:38:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mxngls](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mxngls](https://forums.ankiweb.net/u/Mxngls)\
**Post date:** [July 10, 2022, 12:38pm UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355/1 "2022-07-10T12:38:29Z")

</div>

I am currently writing a web app that lets you create flash cards on the fly. In order to create these I manually create a `.apkg` file. Unfortunately the imports fails due to a JSON error:

`anki.errors.LocalizedError: JsonError("expected value at line 1 column 2")`

Even after continuous effort I was not able to trace down where the error stems from. I copied the `model`, `decks`, `conf` and `dconf` JSON objects from an existing deck that uses the same model as the web app. I do not have media files and thus set the contents of the `media` file to `{}`.

Please see the JSON objects in question:

> **Summary**
>
> `  
> const conf = {“collapseTime”:1200,“\_deck\_0\_lastNotetype”:1657413686850,“schedVer”:2,“newSpread”:0,“curDeck”:1,“activeDecks”:[1],“dueCounts”:true,“nextPos”:2,“estTimes”:true,“timeLim”:0,“sortBackwards”:false,“creationOffset”:-540,“\_nt\_1657413686850\_lastDeck”:0,“sortType”:“noteFld”,“dayLearnFirst”:false,“curModel”:1657413686850,“addToCur”:true}
> 
> const model = {“1657413686850”:{“id”:1657413686850,“name”:“Basic”,“type”:0,“mod”:0,“usn”:0,“sortf”:0,“did”:null,“tmpls”:[{“name”:“Card 1”,“ord”:0,“qfmt”:“{{Front}}”,“afmt”:“{{FrontSide}}\n\n
> 
> * * *
> \n\n{{Back}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0}],“flds”:[{“name”:“Front”,“ord”:0,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Back”,“ord”:1,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”}],“css”:“.card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n”,“latexPre”:“\documentclass[12pt]{article}\n\special{papersize=3in,5in}\n\usepackage[utf8]{inputenc}\n\usepackage{amssymb,amsmath}\n\pagestyle{empty}\n\setlength{\parindent}{0in}\n\begin{document}\n”,“latexPost”:“\end{document}”,“latexsvg”:false,“req”:[[0,“any”,[0]]]},“1657413686854”:{“id”:1657413686854,“name”:“Cloze”,“type”:1,“mod”:0,“usn”:0,“sortf”:0,“did”:null,“tmpls”:[{“name”:“Cloze”,“ord”:0,“qfmt”:“{{cloze:Text}}”,“afmt”:“{{cloze:Text}}  
> \n{{Back Extra}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0}],“flds”:[{“name”:“Text”,“ord”:0,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Back Extra”,“ord”:1,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”}],“css”:“.card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n.cloze {\n font-weight: bold;\n color: blue;\n}\n.nightMode .cloze {\n color: lightblue;\n}\n”,“latexPre”:“\documentclass[12pt]{article}\n\special{papersize=3in,5in}\n\usepackage[utf8]{inputenc}\n\usepackage{amssymb,amsmath}\n\pagestyle{empty}\n\setlength{\parindent}{0in}\n\begin{document}\n”,“latexPost”:“\end{document}”,“latexsvg”:false,“req”:[[0,“any”,[0]]]},“1657413686852”:{“id”:1657413686852,“name”:“Basic (optional reversed card)”,“type”:0,“mod”:0,“usn”:0,“sortf”:0,“did”:null,“tmpls”:[{“name”:“Card 1”,“ord”:0,“qfmt”:“{{Front}}”,“afmt”:“{{FrontSide}}\n\n
> * * *
> \n\n{{Back}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0},{“name”:“Card 2”,“ord”:1,“qfmt”:“{{#Add Reverse}}{{Back}}{{/Add Reverse}}”,“afmt”:“{{FrontSide}}\n\n
> * * *
> \n\n{{Front}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0}],“flds”:[{“name”:“Front”,“ord”:0,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Back”,“ord”:1,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Add Reverse”,“ord”:2,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”}],“css”:“.card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n”,“latexPre”:“\documentclass[12pt]{article}\n\special{papersize=3in,5in}\n\usepackage[utf8]{inputenc}\n\usepackage{amssymb,amsmath}\n\pagestyle{empty}\n\setlength{\parindent}{0in}\n\begin{document}\n”,“latexPost”:“\end{document}”,“latexsvg”:false,“req”:[[0,“any”,[0]],[1,“all”,[1,2]]]},“1657413686851”:{“id”:1657413686851,“name”:“Basic (and reversed card)”,“type”:0,“mod”:0,“usn”:0,“sortf”:0,“did”:null,“tmpls”:[{“name”:“Card 1”,“ord”:0,“qfmt”:“{{Front}}”,“afmt”:“{{FrontSide}}\n\n
> * * *
> \n\n{{Back}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0},{“name”:“Card 2”,“ord”:1,“qfmt”:“{{Back}}”,“afmt”:“{{FrontSide}}\n\n
> * * *
> \n\n{{Front}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0}],“flds”:[{“name”:“Front”,“ord”:0,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Back”,“ord”:1,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”}],“css”:“.card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n”,“latexPre”:“\documentclass[12pt]{article}\n\special{papersize=3in,5in}\n\usepackage[utf8]{inputenc}\n\usepackage{amssymb,amsmath}\n\pagestyle{empty}\n\setlength{\parindent}{0in}\n\begin{document}\n”,“latexPost”:“\end{document}”,“latexsvg”:false,“req”:[[0,“any”,[0]],[1,“any”,[1]]]},“1657413686853”:{“id”:1657413686853,“name”:“Basic (type in the answer)”,“type”:0,“mod”:0,“usn”:0,“sortf”:0,“did”:null,“tmpls”:[{“name”:“Card 1”,“ord”:0,“qfmt”:“{{Front}}\n\n{{type:Back}}”,“afmt”:“{{Front}}\n\n
> * * *
> \n\n{{type:Back}}”,“bqfmt”:“”,“bafmt”:“”,“did”:null,“bfont”:“”,“bsize”:0}],“flds”:[{“name”:“Front”,“ord”:0,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”},{“name”:“Back”,“ord”:1,“sticky”:false,“rtl”:false,“font”:“Arial”,“size”:20,“description”:“”}],“css”:“.card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}\n”,“latexPre”:“\documentclass[12pt]{article}\n\special{papersize=3in,5in}\n\usepackage[utf8]{inputenc}\n\usepackage{amssymb,amsmath}\n\pagestyle{empty}\n\setlength{\parindent}{0in}\n\begin{document}\n”,“latexPost”:“\end{document}”,“latexsvg”:false,“req”:[[0,“any”,[0,1]]]}}
> 
> const deck = {“1”:{“id”:1,“mod”:0,“name”:“Default”,“usn”:0,“lrnToday”:[0,0],“revToday”:[0,0],“newToday”:[0,0],“timeToday”:[0,0],“collapsed”:true,“browserCollapsed”:true,“desc”:“”,“dyn”:0,“conf”:1,“extendNew”:0,“extendRev”:0}}
> 
> const dconf = {“1”:{“id”:1,“mod”:0,“name”:“Default”,“usn”:0,“maxTaken”:60,“autoplay”:true,“timer”:0,“replayq”:true,“new”:{“bury”:false,“delays”:[1.0,10.0],“initialFactor”:2500,“ints”:[1,4,0],“order”:1,“perDay”:20},“rev”:{“bury”:false,“ease4”:1.3,“ivlFct”:1.0,“maxIvl”:36500,“perDay”:200,“hardFactor”:1.2},“lapse”:{“delays”:[10.0],“leechAction”:1,“leechFails”:8,“minInt”:1,“mult”:0.0},“dyn”:false,“newMix”:0,“newPerDayMinimum”:0,“interdayLearningMix”:0,“reviewOrder”:0,“newSortOrder”:0,“newGatherPriority”:0,“buryInterdayLearning”:false}}  
> `

Due to some html and JS usage these are quite convoluted and I suggest you view them in a text editor or an online JSON formatter.

As always thanks in advance!

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [July 11, 2022, 8:09am UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355/2 "2022-07-11T08:09:50Z")

</div>

apkg files were not intended to be created by external programs, and their format is not documented. In the future we’d like to provide a more open format that is easier to write, but at the moment, the only alternative is .csv files

---

<div class="post-metadata">

**Author:** ![Mxngls](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mxngls](https://forums.ankiweb.net/u/Mxngls)\
**Post date:** [July 11, 2022, 8:23am UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355/3 "2022-07-11T08:23:28Z")

</div>

Hi Damien thanks for the reply! I think the lack of documentation is a problem but it’s at least partially addressed by AnkiDroid etc. My problem was simply that I did not follow the database schema due to a typo.  
One suggestion that I have tough: It would be of great help if db errors would at least specify in which db column and line the error occurred.  
Anyway thanks for the great work!

---

<div class="post-metadata">

**Author:** ![Mxngls](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mxngls](https://forums.ankiweb.net/u/Mxngls)\
**Post date:** [July 11, 2022, 8:25am UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355/4 "2022-07-11T08:25:26Z")

</div>

For the record: My problem was only that I included bases at the _beginning_ of the string that composes the `tags` column (Thus the mentioning of `column 2` in the error description).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 1, 2023, 3:15am UTC](https://forums.ankiweb.net/t/jsonerror-expected-value-at-line-1-column-2-import-of-apkg-file-failed/21355/5 "2023-05-01T03:15:10Z")

</div>

Closed on May 1, 2023, 3:15am UTC


