Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont emit anything for empty JSON arrays & Release 1.0.3 #56

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: oq
description: |
A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.

version: 1.0.2
version: 1.0.3

authors:
- George Dietrich <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: oq
version: '1.0.2'
version: '1.0.3'
summary: A performant, and portable jq wrapper to support formats other than JSON
description: |
A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.
Expand Down
9 changes: 2 additions & 7 deletions spec/converters/xml_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ describe OQ::Converters::Xml do
output.should eq(<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a>
<foo/>
</a>
<a/>
</root>\n
XML
)
Expand Down Expand Up @@ -584,7 +582,6 @@ describe OQ::Converters::Xml do
output.should eq(<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a/>
<b/>
<c/>
</root>\n
Expand All @@ -600,9 +597,7 @@ describe OQ::Converters::Xml do
output.should eq(<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<a>
<item/>
</a>
<a/>
</root>\n
XML
)
Expand Down
5 changes: 1 addition & 4 deletions src/converters/xml.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module OQ::Converters::Xml
@@at_root : Bool = true

def self.deserialize(input : IO, output : IO, **args) : Nil
builder = JSON::Builder.new output
xml = XML::Reader.new input
Expand Down Expand Up @@ -137,7 +135,6 @@ module OQ::Converters::Xml
end

private def self.handle_object(builder : XML::Builder, json : JSON::PullParser, key : String? = nil, array_key : String? = nil, *, xml_item : String) : Nil
@@at_root = false
json.read_object do |k|
if k.starts_with?('@')
builder.attribute k.lchop('@'), get_value json
Expand All @@ -160,7 +157,7 @@ module OQ::Converters::Xml
array_key = array_key || xml_item

if json.kind.end_array?
builder.element(array_key) { } unless @@at_root
# If the array is empty don't emit anything
else
until json.kind.end_array?
builder.element array_key do
Expand Down
2 changes: 1 addition & 1 deletion src/oq.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "./converters/*"

# A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.
module OQ
VERSION = "1.0.2"
VERSION = "1.0.3"

# The support formats that can be converted to/from.
enum Format
Expand Down