Skip to content

jshn.sh: Adding array twice gives counterintuitive result #18

@pony1k

Description

@pony1k

The following

#!/bin/sh

. /usr/share/libubox/jshn.sh

json_init

json_add_array array
	json_add_string "" "item1"
	json_add_string "" "item2"
	json_add_string "" "item3"
json_close_array

json_add_array array
	json_add_string "" "itemA"
	json_add_string "" "itemB"
	json_add_string "" "itemC"
json_close_array

json_dump

outputs

{ "array": [ "itemA" ] }

which is surprising. I've expected it to output

{ "array": [ "itemA", "itemB", "itemC" ] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions