Skip to content

Creating Array using PropertyBox #77

Description

@vaithu

How do I create an array using PropertyBox ?

Here is the code I tried to create.

ListPathProperty<String> QUEUE = ListPathProperty.create("queue",String.class);
		StringProperty NAME = StringProperty.create("name").parent(QUEUE);
		StringProperty TYPE = StringProperty.create("type").parent(QUEUE);

		PropertySet<?> PROPERTIES = PropertySet.of(QUEUE, NAME, TYPE);
		PropertyBox pb = PropertyBox.create(PROPERTIES);
		pb.setValue(NAME,"a");
		pb.setValue(TYPE,"local");
		Json json = Json.require();

		List<PropertyBox> boxes = new ArrayList<>();
		boxes.add(pb);

		pb = pb.cloneBox();
		pb.setValue(NAME,"b");
		pb.setValue(TYPE,"remote");

		boxes.add(pb);

		System.out.println(json.toJson(boxes).asString());

The output generated is

[{"queue":{"name":"a","type":"local"}},{"queue":{"name":"b","type":"remote"}}]

whereas I need them as

{"queue": [{"name":"a","type":"local"},{"name":"b","type":"remote"}]}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions