If you want to format/build the APN settings as it's explained in https://bugzilla.mozilla.org/show_bug.cgi?id=842252#c2 there is no need to do it in this way. It's much more easier, note -for example- here https://github.com/mozilla-b2g/gaia/blob/master/shared/resources/apn.json#L140 how the APN settings are stored in apn.json database. You just need to discard those ones related to operator variant stuff (voicemail, and other settings).