Hi,
when we pass an empty key-valye collection to nfjsoncreate I get an error. The input data is similar to this:
```
"nfjson_kv_collection" : {
"collectionitems" : [ ]
}
```
The error rises in function reviveCollection at line
```
For T = 1 To Alen(m.tv.collectionItems)
If m.keyValColl
esteval = m.tv.collectionItems(m.T).Value
```
Looks like collectionItems has a not-zero size even if it's empty
Comments: ** Comment from web user: mplazac **
when we pass an empty key-valye collection to nfjsoncreate I get an error. The input data is similar to this:
```
"nfjson_kv_collection" : {
"collectionitems" : [ ]
}
```
The error rises in function reviveCollection at line
```
For T = 1 To Alen(m.tv.collectionItems)
If m.keyValColl
esteval = m.tv.collectionItems(m.T).Value
```
Looks like collectionItems has a not-zero size even if it's empty
Comments: ** Comment from web user: mplazac **
Hi,
To create a empty collection from Json, use "<collectionName>_kl_collection" instead of "<collectionName>_kv_collection" ( _kl_collection = keyLess collection / _kv_collection = keyValue collection ) like: { "myEmptyCollection_kl_collection": { "collectionitems": [] }}
This is due to the fact that Vfp collection class has no property to indicate if it's key or keyless; ( "The first item added determines the behavior for the collection" )
check it by doing:
o = CREATEOBJECT('collection')
? nfjsoncreate(m.o,.f.,.f.,'myEmptyCollection')
&& {"myEmptyCollection_kl_collection": { "collectionitems": [ ] } }
Marco Plaza