How to use boolean variables in Paw? - paw-app

Are boolean variables supported by Paw? When I import an OpenAPI spec with boolean query parameters, Paw seems to ignore all of that and convert them to strings. Furthermore, if I set a variable to be boolean, it gives a warning that
Parameter '<parameter name>': " is not of type 'boolean'
true/false aren't valid booleans. Then, if I export the collection back to OpenAPI, it converts the field back to a boolean. Does Paw not support booleans?

Related

the way to determine a request parameter is null

the way to determine a request parameter is null in spring
If you're talking about query or form parameters, then these cannot take value null. They are sent as strings; any conversion (e.g. to int) is done by the framework or your own application. So if a query parameter is sent in as ?var=null, then your applications gets 'null' - a string of length 4 containing the word null. So, if your application receives a null, then the query / form parameter was not sent.
It's a different story when you're talking about properties in JSON. If the type is simply String, Integer, etc., then you cannot see the difference between not-present and present as null. You can try using Optional<String> etc., but I haven't tried that myself. For Jackson you can find more information at https://www.baeldung.com/jackson-optional.
to make sure request parameter is not null and is always present you can use
#RequestParam(required = true)
This will make sure parameter is always passed

Cannot deserialize an object using a converter?

Given a JSON string of the form {"$type":"MyType, MyAssembly","seed":0"}, why can't JsonConvert.DeserializeObject utilize the JsonConverter associated with "MyType"?
I've tried decorating the MyType class with a [JsonConverter(typeof(MyType))] attribute. Doesn't work. The custom JsonConverter's ReadJson method is never called.
I've tried adding the custom converter to the serializer's settings Converters collection and made sure the CanConvert method returns true for 'MyType' and the CanRead method returns true. Doesn't work. Neither the converter's CanConvert nor its ReadJson method is ever called.
The DeserializeObject method needs to be able to deserialize a JSON string containing an object whose type is unknown at compile time, but whose type is embedded in the JSON object via the special "$type" member. So don't suggest using DeserializeObject<T> or point out that it works for members, whose type is identified in the contract before hand.
FYI, this problem generalizes to cases where the deserialization needs to identify the object type solely from the embedded "$type" member, so for example, it also fails to resolve a converter if the JSON object is in an untyped JSON array, not just at the top-level.
Basically, an object cannot survive a round trip through the serialization/deserialization process, because although the WriteJson method will be called for the Converter when SerializeObject is called, when you subsequently pass the JSON string to DeserializeObject, it fails to call the converter's ReadJson method, and instead constructs an new instance and uses the basic member population routines.

deserialize integer as boolean asp.net javascriptserializer

I am developing a mobile application which serializes a class containing a couple of boolean properties.
It treats boolean properties as integers, hence serializes them as "0" or "1".
On server side (ASP.NET Web Service), JavascriptSerializer tries to convert "0" to boolean, and gives Error: "0 is not a valid value for Boolean"
I need to modify javascript serializer so that when it encounters a "0" or "1" and expects a boolean, it converts their corresponding value to bool.
I investigated JavascriptConverter abstract class but did not help. Could you support with such a working example?
Thanks in advance
Its better converting true to 1 after Serialization.
Use some wrapper class or custom code

What is the difference between DbType and Type in SqlParameter?

Can you explain me the difference between Type and DbType in a parameter of a datasource?
What is the best pratice of assigning these two properties?
Type Represents type declarations: class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types.
like Int32, String, complex types
it is for front-end referene
ref: http://msdn.microsoft.com/en-us/library/system.type.aspx
While
DBType
Specifies SQL Server-specific data type of a field, property, for use in a SqlParameter.
ref: http://msdn.microsoft.com/en-us/library/system.data.sqldbtype.asp
So this means: you must use Type when referencing from DB to C#/VB
and DBType when referencing/Passing values to DB From C#/VB
Hope this helps...
The answer does not hold good always. For some cases setting DBType of the procedure parameter from VB .Net fails for no reason (even if [param].DBType is set to sqlDBType.Decimal, the [param].sqlDBType got set to DateTime, resulting in an invalid cast error while invoking the procedure with valid decimal values for the parameter). Solution was that I had to set [param].sqlDBType specifically instead of setting the DBType property. Still not clear what all this really implies.
From MSDN docs :
The SqlDbType and DbType are linked. Therefore, setting
the DbType changes the SqlDbType to a supporting SqlDbType.

whats the difference between an object and string object

I think i am lost with basics itself. What is the difference between these two. String object is an instance of String Class.
var guru:Object = new Object();
var guru:String = new String();
An object is a basic object. It has very few intrinsic properties and methods. More detail here
A string is an extended object that has the properties and methods relevant to strings. More detail here
If you're really not sure, I'd suggest looking up the answer here:
http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_11.html
Briefly, it states:
String data type
The String data type represents a
sequence of 16-bit characters. Strings
are stored internally as Unicode
characters, using the UTF-16 format.
Strings are immutable values, just as
they are in the Java programming
language. An operation on a String
value returns a new instance of the
string. The default value for a
variable declared with the String data
type is null. The value null is not
the same as the empty string (""),
even though they both represent the
absence of any characters.
Object data type
The Object data type is defined by the
Object class. The Object class serves
as the base class for all class
definitions in ActionScript. The
ActionScript 3.0 version of the Object
data type differs from that of
previous versions in three ways.
First, the Object data type is no
longer the default data type assigned
to variables with no type annotation.
Second, the Object data type no longer
includes the value undefined, which
used to be the default value of Object
instances. Third, in ActionScript 3.0,
the default value for instances of the
Object class is null.
If that doesn't satisfy your question, you're going to have to get more specific.
This guide can help you with basic Object Oriented questions regarding ActionScript 3.
The reference guide for String states that String inherits directly from Object.
The String class provides a bunch of useful methods that help with string manipulation on top of the few methods that Object provides (like toString()).

Resources