Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6960507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:24:39+00:00 2026-05-27T15:24:39+00:00

I’ve got the following simple scenario: I parse manifest.json (a JSON file) I add

  • 0

I’ve got the following simple scenario:

  1. I parse manifest.json (a JSON file)
  2. I add some paths to an array field of this JSON object
  3. I stringify the object back to JSON and write back to the file

An issue appears somewhere inbetween: when I add a relative path to the array and then output the array I’m getting double backslashes in my output.

This is part of the code:

var entry = manifest['content_scripts'][0]['js'] = [];
    routines.forEach(function(routine) {
        var rel = path.relative(sourcePath, routine);
        console.log('rel %s', rel);
        entry.push(rel);        
        console.log('added rel %s', entry[entry.length-1]);
        console.log('total array %a', entry);
    });

This returns:

rel routines\boot.js
added rel routines\boot.js
total array %a [ 'routines\\boot.js' ]

How is this possible? The first entry in the “total array output” is not equal to the output of directly logging this last entry.

May JSON.stringify be causing issues here?

Extra: for those interested, this is the entire build script:

var path            = require('path'),
    fs              = require('fs'),
    findit          = require('findit'),
    sourcePath      = path.resolve('./src'),
    manifestPath    = path.join(sourcePath, 'manifest.json'),
    routinesDir     = path.join(sourcePath, 'routines');

//find routines
var routines = findit.sync(routinesDir);
if (!Array.isArray(routines) || routines.length === 0) throw new Error('no routines found');

//get file
fs.readFile(manifestPath, 'utf8', function(err, data) {
    if (err) throw err;

    //get manifest
    var manifest = JSON.parse(data);

    //flush and reset js entry
    var entry = manifest['content_scripts'][0]['js'] = [];
    routines.forEach(function(routine) {
        var rel = path.relative(sourcePath, routine);
        console.log('rel %s', rel);
        entry.push(rel);        
        console.log('added rel %s', entry[entry.length-1]);
        console.log('total array %a', entry);
    });

    //get string back
    var manifestStr = JSON.stringify(manifest, null, 4);

    console.log('new manifest: ' + manifestStr);

    //update file
    fs.writeFile(manifestPath, manifestStr, 'utf8', function(err) {
        if (err) throw err;

        //done
        console.log('build done');
    });
});

With manifest.json:

{
“name”: “Name”,
“version”: “0.0.1”,
“description”: “”,
“content_scripts”: [
{
“matches”: [
“http://www.example.com”
],
“js”: [
“routines\boot.js”
],
“css”: [
“prime.css”
],
“run_at”: “document_start”
}
]
}

Finally, I’m running this on Windows 7.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:24:40+00:00Added an answer on May 27, 2026 at 3:24 pm

    You’re using %a in the formatting string, which has no meaning, so console.log inspects the array instead. Probably %a is just a typo and you really meant %s.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.