Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26165

iOS: Requiring a JSON file that contains single quotes throws error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 7.1.1, Release 7.2.0
    • Fix Version/s: Release 7.5.0
    • Component/s: iOS
    • Labels:
    • Story Points:
      0
    • Sprint:
      2018 Sprint 15 SDK

      Description

      Description

      When requiring a JSON file where a value contains a single quote an error like below is thrown, this works fine on Windows/Android

      [ERROR] Script Error {
      [ERROR]     column = 32;
      [ERROR]     line = 2;
      [ERROR]     message = "Unexpected identifier 's'. Expected ')' to end an argument list.";
      [ERROR]     sourceURL = "file:///Users/eharris/Library/Developer/CoreSimulator/Devices/EE6CA02F-4F3A-4407-9929-FEAC97512C66/data/Containers/Bundle/Application/4B53071A-F963-4006-9FEC-DA1C01E87548/ticreateapp.app/jsonfile.json";
      [ERROR]     stack = "    at require@[native code]\n    at global code(/app.js:1:32)";
      [ERROR] }
      [ERROR] Script Error Module "jsonfile.json" failed to leave a valid exports object
      

      Workaround
      Read the file in like JSON.parse(Ti.Filesystem.getFile('file.json').read())

      Steps to reproduce
      1. Add the below into a JSON file under your project

        {
        	"foo": "Singlequotes can ruin one's day"
        }
        

      2. Add a require statement into your code that requires the file
      Actual

      Error like the above is thrown

      Expected

      File should be imported

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              eharris Ewan Harris
              Reviewer:
              Ewan Harris
              Tester:
              Samir Mohammed
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-6427
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code