Quick and Dirty
Once apon a time, my partner asked me if I could install a "note taking application" on her Android phone. I used a version of the "Simple Mobile Tools" Notes app on my phone (downloaded from F-droid), and was happy with it, so I installed the same on her phone (downloaded from Google Play). She, too, was happy with the note-taking tool; so much so that she ultimately wrote over 1300 notes in it.
Recently, we both upgraded our phones, and found that the "Simple Mobile Tools" Notes app didn't appear in either Google Play or F-droid. However, I found an equivalent (possibly fork) of the Notes app on F-droid, which I installed on my new phone. I then "exported" my notes from the app on the old phone, imported them to the app on my new phone, and continued on as before.
But, the migration process wasn't as simple for my partner. We did the same "export" from the old app, but the new app (installed from F-droid, because Google Play doesn't have it), couldn't process the import. Apparently, the Google Play version of this Notes app didn't use the same export format as the F-droid version did.
Being the guy that I am, I made copies of her old phone export file, and of the export file from my old phone, and compared them. Both are JSON, but there were minor differences in the file naming convention, and in the JSON generated on export.
The file name problem was easily fixed with a simple rename of the export file (the name format was obvious), but the JSON data was different. I spent a small bit of time identifying the differences in the JSON; there was one new object for each note (an "id" kvpair, with a counter in it), and one object changed in a predictable manner ("the "type" kvpair, which changed from a number value to an equivalent text value). My problem came down to how I would transform the old export file to meet the new JSON requirements. I had two options:
- treat it like JSON, split it out into objects, modify the object tree, and write the resulting object tree back out as a flat file, or
- treat it as text and perform a simple stream text edit on it
While treating it like JSON would have been the correct choice, I reasoned that the old format file was already in acceptable JSON, and it would be quicker (for my purposes) to just process it as a simple text stream.
So, that's what I did. I tried various tools (sed(1) and awk(1), primarily), but had little luck simplifying the task. Then, I remembered a tool that would make this task easy: flex(1). Yes, it was a strange choice, but it worked.
So, I give you the entire source code for this file transformation. If you have an export file from the "Simple Mobile Tools" Notes app that you have trouble loading into the "Fossify" Notes app, try something like this:
%{
/*
** xform.lex
**
** This program will patch an old android "Notes" json export file
** for import into a new android "Fossify Notes" application
**
** It
** a) adds a unique numeric "id" to each top-level object, and
** b) changes the "type" kvpair from the old format to the new format
** c) transcribes the rest of the json verbatum
**
** Lew Pitcher 2026-07-02
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned int idnum = 8000;
%}
%%
\"path\":\"\", { printf("\"id\":%u,%s",idnum++,yytext); }
\"type\":0, { printf("\"type\":\"TYPE_TEXT\","); }
\"type\":1, { printf("\"type\":\"TYPE_CHECKLIST\","); }
. { putchar(*yytext); }
%%
int main(void) { yylex(); }
int yywrap() { return 1; }
made with this Makefile
xform: lex.yy.c cc -o xform lex.yy.c lex.yy.c: xform.lex lex xform.lex clean: rm -f lex.yy.c xform
To run the program
./xform <The_Old_JSON_file >The_New_JSON_file