Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

{
    "UpdateRequest": {
        "SAASAS": {
            "SPO2": "99.00000",
            "VitalGroupID": "1219",
            "Temperature": "36.6666666666667",            
        },
        "Modified": 1,
        "ID": 25465
    }
}

How can i send VitalGroupID and Temperature as Integer instead of String.... This is the request that get's formed after i hit submit button.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
208 views
Welcome To Ask or Share your Answers For Others

1 Answer

You'll need to show the code that's creating the request when you click the button. Basically, if the object you're serializing contains numbers rather than strings, the resulting JSON will have numbers instead of strings. So the problem is that the object you're serializing has strings instead.

But for instance, if you're getting these values from HTML input fields or similar, e.g.:

UpdateRequest.SAASAS.VitalGroupID = someInputElement.value;

...value is always a string. You'll need to parse it:

UpdateRequest.SAASAS.VitalGroupID = parseInt(someInputElement.value, 10);

Note that it's best to use parseInt and to give it the radix (the number base, usually 10), else you run into issues with numbers written as "08" and similar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...