Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26963] iOS: Require'ing a JSON file appends file path to resulting JSON string

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-10-02T16:56:20.000+0000
Affected Version/sRelease 8.0.0, Release 8.1.0
Fix Version/sRelease 8.2.1
ComponentsiOS
Labelsn/a
ReporterHans Knöchel
AssigneeChristopher Williams
Created2019-04-04T08:02:51.000+0000
Updated2019-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

FileDateSize
currencies.json2019-04-04T08:02:23.000+000017458

Comments

  1. Isaac Whitfield 2019-05-31

    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.
  2. Brenton House 2019-09-16

  3. Christopher Williams 2019-09-30

    backport for 8_2_X: https://github.com/appcelerator/titanium_mobile/pull/11250
  4. Lokesh Choudhary 2019-09-30

    FR Passed. PR's Merged.
  5. Lokesh Choudhary 2019-10-02

    Verified the fix with SDK 8.2.1.v20191001063013 & 8.3.0.v20191001072347. Closing.

JSON Source