Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jason 122 posts 658 karma points
    Jun 29, 2016 @ 15:47
    Jason
    0

    Returned JSON properties are the wrong case and do not match the bindings in Umbraco angular views.

    So this is a weird one and hoping someone might have an idea of how to track down the cause or have an easy fix.

    I was setting up a new Examine index and went to test the new index from the Examine Management dashboard in the Developer section by doing a test search in the Searchers area of the dashboard but ran into an issue with the returned results. I searched on a word I knew would be in the index, results were returned and rows added to the results table but the Score, Id and Value cells in each row were empty. I looked at the Developer Tools in the browser and JSON data with values was returned by the API but the values did not bind to the results table. After I bit more investigation I found that the issue was that the property names in the returned JSON were camel case and the property names in the angular view were title case, i.e. result.score vs. result.Score. Because of this case difference the result data was not bound in the view.

    I tested with another install of Umbraco and the case of the properties matched and work fine, the JSON data was title case which matched the view. Same version of Umbraco, different results formats returned. I am fairly certain that the issue is late to a third party plugin, but I do not know which one and I have to many to simply back them out. I think that I introduced code that is globally forcing camel case for JSON results which is now breaking some of the Umbraco angular binds. Well that is my guess at least.

    Any suggestions on what might be happening and how I might resolve this issue that does not involve editing the Umbraco dashboard code?

  • Mark Bowser 273 posts 860 karma points c-trib
    May 02, 2018 @ 20:50
    Mark Bowser
    0

    Just ran into this myself. One of our sites all of a sudden started enforcing the Json Camel Casing. I first noticed it on some custom dashboards we built for our client and figured it must have been something one of our devs did to Visual Studio or the csproj at some point. I started adding the [JsonCamelCaseFormatter] attribute to our API controllers to and making sure our JS was using camel cased results to prevent any surprises in the future.

    I just realized that this camel casing problem is affecting our backoffice examine dashboard the same way you described, so I am back to looking for the root of the problem. When I look back at our git history for the project, I'm not noticing anything obvious that seems like it could have caused this sort of problem. Did you figure it out yet?

    This site is an Umbraco 7.4.3 site.

  • Mark Bowser 273 posts 860 karma points c-trib
    May 02, 2018 @ 21:52
    Mark Bowser
    0

    I suspect that we have a nuget version conflict. It looks like we have a nuget package that is dependent on Newtonsoft.Json 10.0.2 whereas Umbraco needs one between 6.0.8 && < 9.0.0. I'm a little bit confused about how everything has been working for many months with this conflict. I'd still like to know what triggered it.

  • Mark Bowser 273 posts 860 karma points c-trib
    May 03, 2018 @ 15:34
    Mark Bowser
    0

    I resolved our Newtonsoft.Json version conflicts. Umbraco 7.4.3 came with Newtonsoft.Json 6.0.8. I can't downgrade my other packages far enough to be compatible with a Newtonsoft.Json that old, but I did try Newtonsoft.Json 7.0.1 and 8.0.3. Both are compatible with all my packages and neither solved the problem.

  • Mark Bowser 273 posts 860 karma points c-trib
    May 03, 2018 @ 18:25
    Mark Bowser
    0

    Looks like this is a bug in Umbraco. This is the commit in Umbraco where the bug was fixed. It looks like it was first released in Umbraco 7.5.0. The JsonCamelCaseFormatter attribute that Umbraco provided wouldn't just change the Json formatting of the controller where the attribute was applied. It would apply the change globally.

Please Sign in or register to post replies

Write your reply to:

Draft