Aanchal Singh

Aanchal Singh

  • NA
  • 50
  • 2.7k

Error while Converting jason to dataset

Jun 30 2021 8:55 AM

I have used dll to covert json to dataset Newtonsoft.Json.Linq 

Converting jason to dataset code :

Public Shared Function jsonToDataSet(ByVal jsonString As String) As DataSet
        Try
            Dim xd As XmlDocument = New XmlDocument()
            jsonString = "{ ""rootNode"": {" & jsonString.Trim().TrimStart("{"c).TrimEnd("}"c) & "} }"
            xd = CType(JsonConvert.DeserializeXmlNode(jsonString), XmlDocument)
            Dim ds As DataSet = New DataSet()
            ds.ReadXml(New XmlNodeReader(xd))
            Return ds
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        End Try
    End Function

When I convert the any other jason this code is working fine but when I am conveting given below jason getting error :{"Cannot add a nested relation or an element column to a table containing a SimpleContent column."}. If I replace seats to seat1 it is working fine but i cannot change anything on jason.

Jason :

{ "rootNode": {"status":"success","msg":"","data":{"block_key":"76570415041123","block_time":"7","ticket_detail":{"msrtc":{"reservation_charge":"5.0","asn_amount":"1.0","ac_service_charges":"0.0"},"upsrtc":"NA","hrtc":"NA","rsrtc":"NA"},"total_fare":280,"base_fare":274,"operator_commission_rate":"4.45","agent_commission_rate":"85","commission_without_gst":8.78,"agent_tds_value":0.44,"agent_net_commission":8.34,"transaction_amount":271.66,"test":{"testing":{"tripchild_con":"Y","post_passanger":[{"title":"Mr","name":"Ram","age":"70","sex":"M","birth":"0","seat_no":"45","subtotal":"280.0","total":"280","is_ladies":"false","mobile":"9579597539","email":"[email protected]","id_type":null,"id_number":null,"name_on_id":null,"primary":"True","ac":"false","sleeper":"false"}],"value":{"title":"Mr","name":"Ram","age":"70","sex":"M","birth":"0","seat_no":"45","subtotal":"280.0","total":"280","is_ladies":"false","mobile":"9579597539","email":"[email protected]","id_type":null,"id_number":null,"name_on_id":null,"primary":"True","ac":"false","sleeper":"false"},"senior_citizen_flag":"0","seats":{"seats":["2","5","6","9","10","13","14","15","16","17","18","20","21","22","23","24","25","26","27","28","31","32","33","34","35","37","38","39","40","41","42","45"],"service_id":"724351","fare":"280.0","childFare":"145.0","seniorcitizenfare":"145.0"},"passengerDetails":"seniorfare else casse","adultFare seniorfare else casse":"274.0","tickets_total_basic_fare":274,"adultFare":null} } 

 

 


Answers (1)