
Convert between XML, JSON and YAML, from one format to another.
If you haven't used grunt before, be sure to check out the Getting Started guide.
From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:
npm install grunt-convert --save-dev
Once that's done, add this line to your project's Gruntfile:
grunt.loadNpmTasks('grunt-convert');
If the plugin has been installed correctly, running grunt --help at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a devDependency, which ensures that it will be installed whenever the npm install command is run.
Type: String
Default: undefined
Define content when using unknown extension.
Type: Int
Default: 2
Force indentation ("pretty printing") for JSON and YAML.
Type: Int
Default: 8
Force indentation ("pretty printing") for YAML only.
Type: boolean
Default: false
Use when converting JSON/YAML to XML. Add XML tag header.
See xml2js for other available options
Type: string
Default: ,
Set the field delimiter. One character only.
Type: boolean
Default: true
List of fields or true if autodiscovered in the first CSV line.
See node-csv for other available options.
grunt.initConfig({
convert: {
options: {
explicitArray: false,
},
csv2json: {
src: ['test/fixtures/csv2json.csv'],
dest: 'tmp/result/csv2json.json'
}
}
});
grunt.initConfig({
convert: {
options: {
explicitArray: false,
},
json2xml: {
options: {
xml: {
header: true
}
},
src: ['test/fixtures/sublime.json'],
dest: 'tmp/result/sublime.xml'
}
}
});
grunt.initConfig({
convert: {
json2yml: {
files: [
{
expand: true,
cwd: 'test/fixtures/',
src: ['**/*.json'],
dest: 'tmp/result/',
ext: '.yml'
}
]
}
}
});
grunt.initConfig({
convert: {
options: {
explicitArray: false,
},
xml2yml: {
src: ['convert.xml'],
dest: 'dist/convert.yml'
}
}
});
grunt.initConfig({
convert: {
options: {
explicitArray: false,
},
xml2json: {
files: [
{
expand: true,
cwd: 'test/fixtures/',
src: ['**/*.xml'],
dest: 'tmp/result/',
ext: '.json'
}
]
},
}
});
grunt.initConfig({
convert: {
plist2json: {
files: [
{
expand: true,
cwd: 'test/fixtures/',
src: ['**/*.plist'],
dest: 'tmp/result/',
ext: '.json'
}
]
}
}
});
grunt.initConfig({
convert: {
json2plist: {
files: [
{
expand: true,
cwd: 'test/fixtures/',
src: ['**/*.json'],
dest: 'tmp/result/',
ext: '.plist'
}
]
}
}
});
We welcome all kinds of contributions! The most basic way to show your support is to star the project, and if you'd like to get involved please see the Contributing to grunt-convert guide for information on contributing to this project.
DATE VERSION CHANGES
type option to define content with unknown
extensionJon Schlinkert
Hariadi Hinta
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by grunt-verb on August 15, 2014.