[CLOSED] JSON conversion

  1. #1

    [CLOSED] JSON conversion

    Hi!

    I have a gridpanel where I can add, delete and modify the records and then I have a button with an userParam where I get the changedData of the store.

    Now I need a JSON object to easily navigate the JSON string passed from the .getChangedData() function.

    I found the JSON.deserialize() function but it seems not work because it thrown a null reference exception.

    Here the code:

    ASPX
                <ext:Button ID="btnSavePro" runat="server" Text="Salva Profilo" AutoPostBack="false" Icon="disk">
                    <AjaxEvents>
                        <Click OnEvent="Salva_Profilo">
                            <UserParams><ext:Parameter Name="ChangedData" Value="#{stProfili}.getChangedData()" Mode="Raw" /></UserParams>
                        </Click>
                    </AjaxEvents>
                </ext:Button>
    Code Behind
           Dim strJSON As String = e.UserParams("ChangedData")
           Dim jr As JsonReader = JSON.Deserialize(strJSON)
    The strJSON object contains a string like this: ""Deleted":[{"ID_PROFILO":8,"NOME_PROFILO":"Carne"}],"Updated":[{"ID_PROFILO":18,"NOME_PROFILO":"panini"}],"Created":[{"ID_PROFILO":"","NOME_PROFILO":"insalata"}]"

    but a NullReferenceException was thrown by the function deserialize:

            public static object Deserialize(string value)
            {
                return JavaScriptConvert.DeserializeObject(value); 'here the NullReferenceException
            }
    It's a bug or there's something wrong in my code?

    Thanks!
    Ale
    Last edited by geoffrey.mcgill; Oct 01, 2010 at 7:48 PM. Reason: [CLOSED]
  2. #2

    RE: JSON conversion

    Hi Lex,

    please see this post http://forums.ext.net/showthread.php...=1553-4-1.aspx

    You should call 'save' function of GridPanel and then handle Store events (or if you using UpdateProxy then request will be send to url setted in UpdateProxy). In post described all cases

    If you have questions after reading post then let me know
  3. #3

    RE: JSON conversion

    Hi Ale,

    I'm just wondering if you have you have your sample working now? If yes, maybe you could post an update with the solution or comment on what revision was required.*


    I'd just like to mark this thread as [CLOSED], but only if you're satisfied that the problem has actually been solved.


    Geoffrey McGill
    Founder
  4. #4

    RE: JSON conversion

    Hi Geoff,

    I'm sorry if I didn't answer at this post but I was full of work last week...

    Thank's to Vlad for his answer but the problem doesn't concern the saving approach but the conversion from JSON string to an easily navigate .NET object like the JSONReader, regardless of the operation which generates the JSON.

    Now I temporarily solved the problem, parsing the whole JSON string using split and substring's operations but this isn't a stylish solution! ;)

    Cheers
    Ale

Similar Threads

  1. [FIXED] Bug on Enum conversion
    By JCKodel in forum Bugs
    Replies: 1
    Last Post: Nov 27, 2012, 7:04 AM
  2. Conversion of site.master _layout.cshtml
    By gdog_5021 in forum 2.x Help
    Replies: 0
    Last Post: Jul 21, 2012, 4:21 AM
  3. DateTime conversion error
    By HexElffilter in forum 1.x Help
    Replies: 6
    Last Post: Feb 21, 2012, 11:29 AM
  4. [CLOSED] TimeField Conversion
    By capecod in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 25, 2010, 9:19 AM
  5. Replies: 0
    Last Post: Apr 08, 2010, 5:00 PM

Posting Permissions