Set comma in a return Json

Asked

Viewed 113 times

-1

Guys I’m developing an application in C# with API. It will query and shows the result. Simple thing. But in one of my methods it returns the height of the guy without comma. It comes for example like this: 175.

Can someone help me put a comma in the middle there ? I’m pretty layabout in the C language#

Thanks

var json = JObject.Parse(result);

            pessoa.altura = (string)json["height"];
  • In short: it gives you the result in centimeters and you want in meters?

  • That’s right. Summed up well. kkk

  • This depends on how you are storing it. If you store centimeters, it will return centimeters. Then just apply a conversion to meters, but before it is good to have full knowledge of the domain of your data

  • @Jeffersonquesado I save everything in string, It’s a small app.

1 answer

0


Hello. Use the package newtonsoft json. It allows you to work with greater ease to convert jsons to . net objects and vice versa.

Here you can learn more how to use this library.

I hope I’ve helped.

  • But the problem is not working with JSON, but rather formatting a "175" string in "1.75". Does this library? If yes, it would be nice to add the code snippet to that in your reply.

  • As I mentioned, she parses values in a very simplified way, treating objects, strings, floats, ints, decimals and the like. If you click on the link here that will redirect to the project maintainer page, already at home has a code showing how fluent is the use of the tool. But for ease I will edit the answer with a code snippet.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.