Socket
Socket
Sign inDemoInstall

xform-to-json

Package Overview
Dependencies
73
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    xform-to-json

Translate an XForm XML string to JSON.


Version published
Weekly downloads
3
decreased by-40%
Maintainers
2
Install size
1.14 MB
Created
Weekly downloads
 

Changelog

Source

[1.2.1] - 2017-03-28

Fixed

  • Stricter checking of location fields to avoid mistakenly parsing multi-choice fields as locations #2

Readme

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

Last updated on 29 Mar 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc