[CONTROLLER-654] singleton lists are not rendered as lists by StructuredDataToJsonProvider Created: 29/Jul/14 Updated: 25/Jul/23 Due: 01/Aug/14 Resolved: 01/Aug/14 |
|
| Status: | Resolved |
| Project: | controller |
| Component/s: | restconf |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Colin Dixon | Assignee: | Jozef Gloncak |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: Mac OS |
||
| External issue ID: | 1449 |
| Description |
|
If I have a model with a list of string, like the leaf-list on line 32 here: And I use the builder to add a singleton list of strings like this: When I covert it to JSON, I get a single string, not a list containing a single stiring. That is I get this: } but, I'd expect this: } Is this a bug or expected behavior? If you want to check it out, this patch set has an example: |
| Comments |
| Comment by Jozef Gloncak [ 30/Jul/14 ] |
|
can you please specify how you convert NDMmeta object to JSON? |
| Comment by Jozef Gloncak [ 30/Jul/14 ] |
|
Please, ignore my question. I have found it. |
| Comment by Jozef Gloncak [ 30/Jul/14 ] |
|
Incorrect output is caused by incorrect using of First parameter of writeTo method is of type StructuredData. It was created with parameters
You have to specify schema for concrete node. You can find concrete schema node in schema context:
The behavior when an entry of leaf-list was outputted like leaf and not like list of leaves was default behavior for case when schema for node isn't presented. |
| Comment by Colin Dixon [ 01/Aug/14 ] |
|
Thanks for the help. For those who care, I modified Jozef's code to make it generic and you can find it here: I think most of the functionality or at least the getSchemaNodeForDataObject should be moved into the SchemaContext implementation where we can maintain a map from Class (and/or QName) to DataSchemaNode. |