[TIMOB-26963] iOS: Require'ing a JSON file appends file path to resulting JSON string
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-10-02T16:56:20.000+0000 |
Affected Version/s | Release 8.0.0, Release 8.1.0 |
Fix Version/s | Release 8.2.1 |
Components | iOS |
Labels | n/a |
Reporter | Hans Knöchel |
Assignee | Christopher Williams |
Created | 2019-04-04T08:02:51.000+0000 |
Updated | 2019-10-02T16:56:20.000+0000 |
Description
When using
require()
to load a JSON file on iOS, the filename and base-url are appended to the final JSON object.
Example:
const data = require('currencies.json');
console.log(data);
Workaround:
const data = JSON.parse(Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'currencies.json').read());
Attachments
File | Date | Size |
---|---|---|
currencies.json | 2019-04-04T08:02:23.000+0000 | 17458 |
I filed a quick PR for this in https://github.com/appcelerator/titanium_mobile/pull/10929 - the fields seem old and are likely redundant. Everything worked in my test app, so I'd assume they're ok to be removed.
backport for 8_2_X: https://github.com/appcelerator/titanium_mobile/pull/11250
FR Passed. PR's Merged.
Verified the fix with SDK 8.2.1.v20191001063013 & 8.3.0.v20191001072347. Closing.