NNKL.COM
welcome to my space
X
Search:  
 HOME   JsonReader / Store issue with json string
JsonReader / Store issue with json string
Published by: anonym 2010-03-18
Welcome to:nnkl.com

  • Hello All,

    I have a JSON string that is formated as such:

    {'total':999,'rows':[{'1','Bob','Gardener"},{'2','Bill','Accountant'}]}

    I havn't been able to figure out how to use this in a JsonReader or JsonStore because the values have no names attached to them and I havn't figured out how to map names to them. So if I try to do:


    var store = new Ext.data.JsonStore({
    root: 'rows',
    data: data,
    fields: ['id','name','occupation']
    });


    The store has no idea what I am trying to get. Is there a way to use an ArrayReader inside of a JsonReader so I can get down to the root of rows and then use an ArrayReader to get the arrays out of there?

    I'm sure this is a simple problem but I just can't seem to find the answer. Any help will be greatly appreciated.

    Thank you for your time.


  • The json you return has to be formatted correctly to map to the store.
    Cutter's Crossing: ColdFusion 8 Json Return Format and ExtJS::
    May 5, 2008 ColdFusion Development, Life, and Other Stuff: ColdFusion 8 Json Return Ext provides a number of 'Store' types, and 'reader's for parsing through them. with this issue, and parked a solution right on the Ext Forums. It's in the way that Ext's JsonReader expects the data to be formatted.
    http://blog.cutterscrossing.com/index.cfm/2008/5/5/ColdFusion-8-Json-Return-Format-and-ExtJS
    HOME
    {'total':999,'rows':[{id:'1',name:'Bob',occupation:'Gardener"},{id:'2',name:'Bill',occupation:'Accountant'}]}
    That's what I was afraid of. It looks like we are going to have to redo our JSONHelper class to format the JSON correctly.

    Thank you for your reply.


  • If you are creating JSON strings using your own classes, I suggest you look at the code at http://json.org/ It's excellent. We use the Java version to create all our configs that are set up by server-side analogs of UI controls.
    We are using the java versions of the JSON helpers but we downloaded them a long time ago (before I got to this job) and I believe they made their own JSONHelper method to create a JSON Array vice a JSON Object due to the requirements of some graphing software they were using.

    I might have to look into the code a little more and find/write a better method to use than the one we are currently using.

    This is an uphill battle right now because the developers I work with have built similar things to those that are in Ext (i.e. event manager, combo boxes, generic table builder), but none of those things talk to each other properly and in some instances Ext does them better, but because we already have all this functionality and we have to meet our deadlines, it is difficult for them to look into Ext as an alternative.

    Ext is faster, more optimized, and better suited for our tasks, but getting developers, that are both stuck in their ways and in a time crunch, to look at Ext is going to be interesting.

    Thanks for your help, it is greatly appreciated.

    BTW, Animal, I especially appreciate the Java code that you place on the forums. I'm very new to Java (and Struts and MVC), so seeing your examples has helped me understand a few things. I know these forums are really for Ext and client side implementation, but it seems like it would be a great idea to have a server side implementation section where people who are new to Java (php, asp, coldfusion) could go an find advice on how to properly build the server side code so that it is easier to implement with Ext. Just a thought, and thank you again for your great help.


  • Yes, you are. That "JSON" was not a valid Javascript object literal.

    Just try using the statement


    var x = {'1','Bob','Gardener"};


    You could use an ArrayReader, and use


    ['1','Bob','Gardener"]


  • The json you return has to be formatted correctly to map to the store.
    {'total':999,'rows':[{id:'1',name:'Bob',occupation:'Gardener"},{id:'2',name:'Bill',occupation:'Accountant'}]}


  • If you are creating JSON strings using your own classes, I suggest you look at the code at http://json.org/ It's excellent. We use the Java version to create all our configs that are set up by server-side analogs of UI controls.





  • Get Smart About Monitoring Virtual Machines
    Microsoft Gets Ex-Streamly Cozy with U.K.'s MediaWave

    You are looking at:nnkl.com's JsonReader / Store issue with json string, click nnkl.com to home
  • what does mean this letter
  • what type of question gets the most answers
  • is yahoo bookmarks
  • how do i get a picture on yahoo answers
  • what do you like best about yahoo answers
  • what do you think when people who supposed give you good answers give you abuse
  • i have a few science questions that need answering
  • how many deleted questions
  • when a 039 zach morris 039 person connects to me why is his profile page called ringo starr
  • asking questions on yahoo
  • do you have questions about the big 3 auto makers
  • did you know that people are answering yahoo questions with
  • how do you get to a higher level on yahoo answers
  • people what 039 s so special about getting to level 2 on yahoo answers
  •  
  • why can 039 t i see my starred questions
  • how many lcd monitors have you ruined by trying to fold back the corner
  • how do i add someone to answers
  • how do you report someone on yahoo anwers
  • is the auto industry as good as dead
  • how can i delete browsing history
  • how do you put up a picture on here
  • on the big auto manufactors
  • is the uaw auto union happy now
  • i was reading fiction and lost control do you think my book will be permanently marked
  • how do you feel about the auto bailout that isn 039 t going to happen
  • is warren buffett salivating or sweating
  • can anyone answer this question
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 nnkl.com        Site made:CFZ