项目作者: MrBogomips

项目描述 :
Newtonsoft JObject Custom Converter enforcing NamingStrategy (PoC)
高级语言: C#
项目地址: git://github.com/MrBogomips/JObjectNamingStrategyConverter.git


JObject NamingStrategy PoC

Newtonsoft default serializer doesn’t honour the NamingStrategy
for JObject objects.

In this PoC I’ve implemented a simple JObject Custom Converter
that force to reinterpret JObject’s properties name with
a provided NamingStrategy.

Output

  1. NOT WORKING SNAKE CASE (JObject's properties aren't serialized accordingly
  2. {
  3. "first_name": "Calpurnio",
  4. "ancient_age": 666,
  5. "custom_data": {
  6. "SimpleString": "Value",
  7. "Ciccio": [
  8. 1,
  9. 2,
  10. "buffo"
  11. ],
  12. "CalpurnioSiculo": {
  13. "AbraCadaBra": true
  14. },
  15. "i_Am_an_Ugly_Snake": {
  16. "i_am_a_cool_snake": "yeah"
  17. }
  18. }
  19. }
  20. WORKING SNAKE CASE
  21. {
  22. "first_name": "Calpurnio",
  23. "ancient_age": 666,
  24. "custom_data": {
  25. "simple_string": "Value",
  26. "ciccio": [
  27. 1,
  28. 2,
  29. "buffo"
  30. ],
  31. "calpurnio_siculo": {
  32. "abra_cada_bra": true
  33. },
  34. "i_am_an_ugly_snake": {
  35. "i_am_a_cool_snake": "yeah"
  36. }
  37. }
  38. }