knipknap / Gelatin
Licence: mit
Transform text files to XML, JSON, or YAML
Stars: ✭ 150
Programming Languages
python
139335 projects - #7 most used programming language
Projects that are alternatives of or similar to Gelatin
Choetl
ETL Framework for .NET / c# (Parser / Writer for CSV, Flat, Xml, JSON, Key-Value, Parquet, Yaml, Avro formatted files)
Stars: ✭ 372 (+148%)
Mutual labels: json, xml, yaml, parser
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+406%)
Mutual labels: json, xml, yaml, parser
Oq
A performant, and portable jq wrapper to facilitate the consumption and output of formats other than JSON; using jq filters to transform the data.
Stars: ✭ 132 (-12%)
Mutual labels: json, xml, yaml
Ansible Config encoder filters
Ansible role used to deliver the Config Encoder Filters.
Stars: ✭ 48 (-68%)
Mutual labels: json, xml, yaml
Countries States Cities Database
🌍 World countries, states, regions, provinces, cities, towns in JSON, SQL, XML, PLIST, YAML, and CSV. All Countries, States, Cities with ISO2, ISO3, Country Code, Phone Code, Capital, Native Language, Timezones, Latitude, Longitude, Region, Subregion, Flag Emoji, and Currency. #countries #states #cities
Stars: ✭ 1,130 (+653.33%)
Mutual labels: json, xml, yaml
Omniparser
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc.
Stars: ✭ 148 (-1.33%)
Mutual labels: json, xml, parser
Xml Js
Converter utility between XML text and Javascript object / JSON text.
Stars: ✭ 874 (+482.67%)
Mutual labels: json, xml, parser
Remarshal
Convert between CBOR, JSON, MessagePack, TOML, and YAML
Stars: ✭ 421 (+180.67%)
Mutual labels: json, yaml, converter
Internettools
XPath/XQuery 3.1 interpreter for Pascal with compatibility modes for XPath 2.0/XQuery 1.0/3.0, custom and JSONiq extensions, XML/HTML parsers and classes for HTTP/S requests
Stars: ✭ 82 (-45.33%)
Mutual labels: json, xml, parser
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-45.33%)
Mutual labels: json, yaml, converter
Structured Text Tools
A list of command line tools for manipulating structured text data
Stars: ✭ 6,180 (+4020%)
Mutual labels: json, xml, yaml
Fast Xml Parser
Validate XML, Parse XML to JS/JSON and vise versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback
Stars: ✭ 1,021 (+580.67%)
Mutual labels: json, xml, parser
Countries
World countries in JSON, CSV, XML and Yaml. Any help is welcome!
Stars: ✭ 5,379 (+3486%)
Mutual labels: json, xml, yaml
Feedr
Use feedr to fetch the data from a remote url, respect its caching, and parse its data. Despite its name, it's not just for feed data but also for all data that you can feed into it (including binary data).
Stars: ✭ 56 (-62.67%)
Mutual labels: json, xml, yaml
Yq
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Stars: ✭ 1,688 (+1025.33%)
Mutual labels: json, xml, yaml
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (+160.67%)
Mutual labels: json, xml, parser
Jokeapi
A REST API that serves uniformly and well formatted jokes in JSON, XML, YAML or plain text format that also offers a great variety of filtering methods
Stars: ✭ 71 (-52.67%)
Mutual labels: json, xml, yaml
Swurg
Parse OpenAPI documents into Burp Suite for automating OpenAPI-based APIs security assessments (approved by PortSwigger for inclusion in their official BApp Store).
Stars: ✭ 94 (-37.33%)
Mutual labels: json, yaml, parser
Gelatin
Summary
Gelatin is a parser generator for converting text to a structured format such as XML, JSON or YAML.
Do you need commercial support?
Gelatin is supported by Procedure 8. Get in touch if you need anything!
Converting Text to XML, JSON, or YAML
Gelatin is a combined lexer, parser, and output generator. Gelatin defines a simple language for converting text into a structured formats.
Example
Suppose you want to convert the following text file to XML:
User
----
Name: John, Lastname: Doe
Office: 1st Ave
Birth date: 1978-01-01
User
----
Name: Jane, Lastname: Foo
Office: 2nd Ave
Birth date: 1970-01-01
The following Gelatin syntax does the job:
# Define commonly used data types. This is optional, but
# makes your life a litte easier by allowing to reuse regular
# expressions in the grammar.
define nl /[\r\n]/
define ws /\s+/
define fieldname /[\w ]+/
define value /[^\r\n,]+/
define field_end /[\r\n,] */
grammar user:
match 'Name:' ws value field_end:
out.add_attribute('.', 'firstname', '$2')
match 'Lastname:' ws value field_end:
out.add_attribute('.', 'lastname', '$2')
match fieldname ':' ws value field_end:
out.add('$0', '$3')
match nl:
do.return()
# The grammar named "input" is the entry point for the converter.
grammar input:
match 'User' nl '----' nl:
out.open('user')
user()
Explanation
- "grammar input:" is the entry point for the converter.
- "match" statements in each grammar are executed sequentially. If a match is found, the indented statements in the match block are executed. After reaching the end of a match block, the grammar restarts at the top of the grammar block.
- If the end of a grammar is reached before the end of the input document was reached, an error is raised.
- "out.add('$0', '$3')" creates a node in the XML (or JSON, or YAML) if it does not yet exist. The name of the node is the value of the first matched field (the fieldname, in this case). The data of the node is the value of the fourth matched field.
- "out.open('user')" creates a "user" node in the output and selects it such that all following "add" statements generate output relative to the "user" node. Gelatin leaves the user node upon reaching the out.leave() statement.
- "user()" calls the grammar named "user".
This produces the following output:
<xml>
<user lastname="Doe" firstname="John">
<office>1st Ave</office>
<birth-date>1978-01-01</birth-date>
</user>
<user lastname="Foo" firstname="Jane">
<office>2nd Ave</office>
<birth-date>1970-01-01</birth-date>
</user>
</xml>
Method 1: Starting the transformation using the CLI tool
The following command converts the input to XML:
gel -s mysyntax.gel input.txt
The same for JSON or YAML:
gel -s mysyntax.gel -f json input.txt
gel -s mysyntax.gel -f yaml input.txt
Method 2: Starting the transformation using Gelatin as a Python Module
Gelatin also provides a Python API for transforming the text:
from Gelatin.util import compile, generate
# Parse your .gel file.
syntax = compile('syntax.gel')
# Convert your input file to XML, YAML, and JSON.
print(generate(syntax, 'input.txt'))
print(generate(syntax, 'input.txt', format='yaml'))
print(generate(syntax, 'input.txt', format='json'))
Documentation
For full documentation please refer to
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].