Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xform-to-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xform-to-json

Translate an XForm XML string to JSON.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

XForm to JSON converter

Converts XForm submissions from ODK Collect to json or geojson.

Usage

var xform2json = require('xform-to-json');

xform2json(xmlString, function(err, json) {
    console.log(json);
})

xform2json(xmlString, [options], callback)

ODK sends an xml file with a single root node, which is discarded.

By default the following metadata is created in the json output:

form.meta = {
  instanceId: form.meta.instanceID || 'uuid:' + uuid.v1(),
  instanceName: form.meta.instanceName || formKey,
  formId: form.$.id,
  version: form.$.version
};

Where:

form.meta is the original meta data from the ODK xml submission formKey is the name of the original xml root node form.$.id and form.$.version are the two attributes on the root node from ODK xml.

options.geojson

When set to true will output geojson, using a geopoint field from the xml for the coordinates if present. If more than one geopoint field is present, the field is chosen arbitrarily unless options.locationField is set (see below). If no geopoint / location field is found then geojson geometry is null.

options.locationField

The fieldname to use for the geojson coordinates.

options.meta

Pass a hash of any metadata values to add to the form, e.g. meta.submissionTime.

Contributors

FAQs

Package last updated on 26 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc