• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Jison Spec

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Jison Spec

    Any of you keyboard kids tell me why the returned JISON from a web service captilises and adds underscores to variable names?

    So CompanyCode in my server code becomes companY_CODE in the JISON.

    I Feel like I need a crystal ball.

    #2
    Originally posted by The James Room View Post
    Any of you keyboard kids tell me why the returned JISON from a web service captilises and adds underscores to variable names?

    So CompanyCode in my server code becomes companY_CODE in the JISON.

    I Feel like I need a crystal ball.
    Nope, but I can recommend you post this in the "Technical" section - or suffer the consequences, you clueless twat!
    Old Greg - In search of acceptance since Mar 2007. Hoping each leap will be his last.

    Comment


      #3
      Originally posted by Zigenare View Post
      Nope, but I can recommend you post this in the "Technical" section - or suffer the consequences, you clueless twat!
      Easy soldier - I didnt't realise there was a technical Subby.

      Comment


        #4
        Originally posted by Zigenare View Post
        Nope, but I can recommend you post this in the "Technical" section - or suffer the consequences, you clueless twat!
        Thread moved - back in your crate, hound.

        Comment


          #5
          Originally posted by The James Room View Post
          Any of you keyboard kids tell me why the returned JISON from a web service captilises and adds underscores to variable names?

          So CompanyCode in my server code becomes companY_CODE in the JISON.

          I Feel like I need a crystal ball.
          So I dont know why a web service would expect CompanyCode and return Company_code. I don't think there is consistent approach to json property names but I would expect the input and output to be the same.

          What does the web service documentation say?

          Comment


            #6
            Originally posted by woohoo View Post
            So I dont know why a web service would expect CompanyCode and return Company_code. I don't think there is consistent approach to json property names but I would expect the input and output to be the same.

            What does the web service documentation say?
            There isn't any. I wrote it.

            Perhaps this is the way that .net API serialises Jison.

            Comment


              #7
              Originally posted by The James Room View Post
              There isn't any. I wrote it.

              Perhaps this is the way that .net API serialises Jison.
              Show me the codez.

              Comment


                #8
                Originally posted by woohoo View Post
                Show me the codez.
                Bisically:

                public IActionResult GetCompanies()
                {
                return Json(this._service.GetCompanies());
                }

                Comment


                  #9
                  Originally posted by The James Room View Post
                  Bisically:

                  public IActionResult GetCompanies()
                  {
                  return Json(this._service.GetCompanies());
                  }
                  If you are using ASP.NET Core MVC and you have this in the Startup.cs then it will convert your property names to company_name. Just remove it and it should default to camel case. I don't think its the default, so you may have added it? Don't know without seeing the code that you have.

                  Code:
                      services.AddMvc().AddJsonOptions(o =>
                      {
                          o.SerializerSettings.ContractResolver = new DefaultContractResolver()
                          {
                              NamingStrategy = new SnakeCaseNamingStrategy()
                          };
                      });
                  Last edited by woohoo; 26 September 2018, 06:24.

                  Comment


                    #10
                    Originally posted by woohoo View Post
                    If you are using ASP.NET Core MVC and you have this in the Startup.cs then it will convert your property names to company_name. Just remove it and it should default to camel case. I don't think its the default, so you may have added it? Don't know without seeing the code what you have.

                    Code:
                        services.AddMvc().AddJsonOptions(o =>
                        {
                            o.SerializerSettings.ContractResolver = new DefaultContractResolver()
                            {
                                NamingStrategy = new SnakeCaseNamingStrategy()
                            };
                        });
                    Amizing!

                    Comment

                    Working...
                    X