Skip to content

when parsing a json array, [] object yielded at end #7

@ilackarms

Description

@ilackarms

i've noticed that when i parse an array, after yielding each of the objects in the array, an empty array object [] is yielded at the end

reproduce:

input:

{ "kind": "PodList", "apiVersion": "v1", "metadata": { "selfLink": "/api/v1/pods", "resourceVersion": "1315" }, "items": [ { "metadata": { "name": "redis-master3", "namespace": "default", "selfLink": "/api/v1/pods/redis-master3?namespace=default", "uid": "1da148b4-cef5-11e4-ac24-3c970e4a436a", "resourceVersion": "1301", "creationTimestamp": "2015-03-20T13:34:48+02:00", "labels": { "mylabel": "mylabelvalue", "role": "pod" } }, "spec": { "volumes": null, "containers": [ { "name": "master", "image": "dockerfile/redis", "ports": [ { "hostPort": 6379, "containerPort": 6379, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "100m" } }, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent", "securityContext": { "capabilities": {} } }, { "name": "php-redis", "image": "kubernetes/example-guestbook-php-redis", "ports": [ { "hostPort": 8000, "containerPort": 80, "protocol": "TCP" } ], "resources": { "limits": { "cpu": "100m", "memory": "50000000" } }, "terminationMessagePath": "/dev/termination-log", "imagePullPolicy": "IfNotPresent", "securityContext": { "capabilities": {} } } ], "restartPolicy": { "always": {} }, "dnsPolicy": "ClusterFirst" }, "status": { "phase": "Pending" } } ] }

parsing code:

streamer.get(key: 'items') do |object| p object end

result:

{"metadata"=>{"name"=>"redis-master3", "namespace"=>"default", "selfLink"=>"/api/v1/pods/redis-master3?namespace=default", "uid"=>"1da148b4-cef5-11e4-ac24-3c970e4a436a", "resourceVersion"=>"1301", "creationTimestamp"=>"2015-03-20T13:34:48+02:00", "labels"=>{"mylabel"=>"mylabelvalue", "role"=>"pod"}}, "spec"=>{"volumes"=>nil, "containers"=>[{"name"=>"master", "image"=>"dockerfile/redis", "ports"=>[{"hostPort"=>6379, "containerPort"=>6379, "protocol"=>"TCP"}], "resources"=>{"limits"=>{"cpu"=>"100m"}}, "terminationMessagePath"=>"/dev/termination-log", "imagePullPolicy"=>"IfNotPresent", "securityContext"=>{"capabilities"=>{}}}, {"name"=>"php-redis", "image"=>"kubernetes/example-guestbook-php-redis", "ports"=>[{"hostPort"=>8000, "containerPort"=>80, "protocol"=>"TCP"}], "resources"=>{"limits"=>{"cpu"=>"100m", "memory"=>"50000000"}}, "terminationMessagePath"=>"/dev/termination-log", "imagePullPolicy"=>"IfNotPresent", "securityContext"=>{"capabilities"=>{}}}], "restartPolicy"=>{"always"=>{}}, "dnsPolicy"=>"ClusterFirst"}, "status"=>{"phase"=>"Pending"}} [] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions