I have collected some data. However, it's too long to paste into a line. How to load from a text file or JSON file .etc?
I have collected some data. However, it's too long to paste into a line. How to load from a text file or JSON file .etc?
If this is hardcoded data for unit tests, you could use JSON data (not available for old watches):
https://developer.garmin.com/connect-iq/core-topics/resources/#jsondata
But unfortunately it willl be included when you upload the app to the store, unless you take steps to remove it when you're done with tests.
(EDIT: Although it won't really make a difference whether the sample data is deployed with the real app or not, I think.)
If it's really just for unit tests, can you just hardcode the data as an array in your unit test function? It doesn't literally have to be a single line.
I imagine that would be terrible for maintenance though.
You could write code that auto-generates your unit test function from a separate text/JSON file, though.
Yeah but if you have a long array (or any other kind of long line) you beautify it so it doesn't occupy a whole line.
var x = [
1, 2, 3, 4, 5, ..., 10,
// ...
100000000,
// ...
// etc
];
Or you could load a JSON resource, but then it gets uploaded to the store. As long as you don't exceed whatever the max size is, it doesn't matter, but it doesn't seem worth it if you don't have to.
The advantage of having it as code is that you can annotate it with :test and make sure it has no impact on the real app.
I am going to release my app now. Thanks for your help over the last 2 weeks. jim_m_58 FlowState
If you are interested in it, you are welcome to download and experience the next version of my app. Note that it is not the upcoming version. If you have any comments and suggestions, please point them out.