Posts

Conditional JSON serialization using C# -

i have class serialize json in c# , post restful web service. have requirment if 1 field filled out field not present. service errors if both fields serialized json object. class looks this: [datacontract(name = "test-object")] public class testobject { [datamember(name = "name")] public string name { get; set; } // if string-value not null or whitespace not serialize bool-value [datamember(name = "bool-value")] public bool boolvalue { get; set; } // if string-value null or whitespace not serialize [datamember(name = "string-value")] public string stringvalue { get; set; } } as noted in comments, if stringvalue has value don't put boolvalue in json object. if stringvalue blank, don't put in stringvalue instead put in boolvalue. i found how xml serialization, cannot find way works json serialization. there conditional json serialization on c#? it appears using datacontractjsonse...

c# - Lucene.Net Query with two MUST Clauses Returning Incorrect Results -

i've created query 2 must clauses (and 0 should clauses) returning results satisfy 1 of clauses. far can tell, incorrect behavior. an example of such query before searching {+(text:wba) +(attribute:10)} the incorrect results being returned have 'wba' term in 'text' field, not have '10' term in 'attribute' field. when @ index in luke, go search tab, , run search +text:wba +attribute:10 i no results, expect. here's simplified version of code run search: public static scoredoc[] search( string searchphrase, int maxresults, ienumerable<string> attributes ) { var topquery = new booleanquery(); var textquery = new booleanquery(); using( var nganalyzer = new ngramanalyzer( version.lucene_30, 3, 9 ) ) { using( var stanalyzer = new standardanalyzer( version.lucene_30, new hashset<string>() ) ) { var ngparser = new queryparser( version.lucene_30, indexmanager.textfieldname, nganalyzer ); ...

android - Resources$NotFoundException: Resource ID #0x0 issue -

this problem annoying me since have no clue might causing it. have few reports of error, samsung devices running android 2.3.5 , 2.3.6 (98%). below stack trace: android.content.res.resources$notfoundexception: resource id #0x0 @ android.content.res.resources.getvalue(resources.java:892) @ android.content.res.resources.getdrawable(resources.java:580) @ android.widget.textview$handleview.setorientation(textview.java:8355) @ android.widget.textview$handleview.<init>(textview.java:8324) @ android.widget.textview$insertionpointcursorcontroller.<init>(textview.java:8631) @ android.widget.textview.getinsertioncontroller(textview.java:9218) @ android.widget.textview.ontouchevent(textview.java:7137) @ android.view.view.dispatchtouchevent(view.java:3885) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:869) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:869) @ android.view.viewgroup.dispatchtouchevent(viewgroup.j...

No Shipping Options Available - Opencart 1.5.6 fedex -

i'm attempting set opencart store client. i'm getting following error on shipping page. "warning: no shipping options available. please contact assistance!" research suggests error happens when there mismatch between weight-class store , plugin, or similar. i've tried every combination of configuration settings can think of without result. i'm not familiar enough opencart debug issue. need start looking? firstly have enable shipping status , values admin panel shipping tab.after can in front end.

javascript - Call same ajax from different element clicks with different data -

i'm trying call same ajax function different elements different data. for eg: i've these 2 links <a href="#!" id="link1" data-source="google">google</a> <a href="#!" id="link2" data-source="facebook">facebook</a> and ajax call like: $("#link1).click(function() { $.post( '/myphpscript/', { data:$("#link1).attr('data-source') }, // data want send script function (data) { } }); i know can call same ajax different elements this: $('#link1, #link2').click(some_function); but how select data based on clicking element? use instance of this , also, give links common class , use simple selector: $(".ajaxlinks").click(function() { $.post('/myphpscript/', { data:$(this).attr('data-source') }, function (data) { }); });

Python - Wrong directory when execute from terminal -

if run ide dir path ok, when execute termianl, geeting exception: code: def __init__(self): dir = os.path.abspath(os.path.join(__file__, os.pardir)) self.locator_file_path = dir+'/locators/locator_'+self.get_class_name_lower()+'.json' open(self.locator_file_path) json_data: exception: e ====================================================================== error: test_verify_page (test_verify_page.testverifypage) ---------------------------------------------------------------------- traceback (most recent call last): file "test_verify_page.py", line 9, in test_verify_page sign_inpage = signinpage() file "c:\python27\lib\site-packages\page_objects\sign_in_page.py", line 47, in __init__ open(self.locator_file_path) json_data: ioerror: [errno 2] no such file or directory: 'c:\\python27\\lib\\site-packages\\page_objects/locators/locator_signinpage.json' ---------------------------------------------...

mysql - Query with two NOT IN subqueries -

is possible have query 2 not in on 2 subqueries: select u.feedbackid user_feedback u u.feedbackid not in ( select feedbackid user_feedback_sent) , not in (select feedbackid user_feedback_received) the query throws error on second not in saying incorrect syntax. you're missing column name shuold not in second subquery. works need: select u.feedbackid user_feedback u u.feedbackid not in (select a.feedbackid user_feedback_sent a) , u.feedbackid not in (select b.feedbackid user_feedback_received b) identation practice implement when writing sql code. hope helps