Select to view content in your preferred language

Hashtable to JSON

4035
0
01-25-2012 12:55 AM
StevenColeman-Williams
Emerging Contributor
Hi all,
I have the following code

var shaftCollection:ArrayCollection = new ArrayCollection();

 for(var i:uint = 0; i < shaftsManager.shafts.length; i++) {
  var shaft:Shaft = shaftsManager.shafts;

  var shaftHash:Hashtable = new Hashtable;

  shaftHash.add("name", shaft.shaftName);
  shaftHash.add("priority", shaft.priorityInt);

  if(shaft.openSpace == null) {
   //we have properties
  }
  else {
   //we have an open space
  }

  shaftCollection.addItem(shaft);
 }

 jsonVar.add("inspection-area", insprectionArea);
 jsonVar.add("shafts", shaftCollection);

 Alert.show(JSON.encode(jsonVar));


unfortunately the JSON that is returned is "{size:2}" and not a nice long string of JSON

why is this? and how do I go about converting a Hashtbale (or similar) to a JSON string?
Tags (2)
0 Kudos
0 Replies