gpt4 book ai didi

java - 快速将复杂的json转换为java对象

转载 作者:行者123 更新时间:2023-12-01 06:25:46 25 4
gpt4 key购买 nike

我有一个来自服务器的复杂 JSON,需要将其转换为 java 对象。

{"menus":[{"title":"Jewellery","menu_columns":[{"title":"category","menu_items":[{"title":"Earrings"},{"title":"Necklaces"},{"title":"Necklace Sets"},{"title":"Anklets"},{"title":"Mangalsutra"},{"title":"Pendants"},{"title":"Bangles \u0026 Bracelets"},{"title":"Rings"},{"title":"Maang Tikka"},{"title":"Keychains"},{"title":"Baju Band"},{"title":"Brooch"},{"title":"Hair Pins"},{"title":"Jewellery Box"},{"title":"Nose Ring"},{"title":"Waist Belts"},{"title":"Jewellery Combo"},{"title":"Watches"},{"title":"Other"}]},{"title":"Type","menu_items":[{"title":"Bridal Jewellery"},{"title":"Temple Jewellery"},{"title":"Statement Jewellery"},{"title":"Thewa Jewellery"},{"title":"Handmade Jewellery"},{"title":"Filigree Jewellery"},{"title":"Pearl Jewellery"},{"title":"High End Jewellery"},{"title":"Ethnic Jewellery"},{"title":"Kundan Jewellery"},{"title":"Jhumkas"}]},{"title":"Earrings","menu_items":[]}]},{"title":"Sarees","menu_columns":[{"title":"by fabric","menu_items":[{"title":"Cotton Sarees"},{"title":"Art Silk Sarees"},{"title":"Georgette Sarees"},{"title":"Chiffon Sarees"},{"title":"Net Sarees"},{"title":"Crepe Sarees"},{"title":"Silk Sarees"},{"title":"Viscose Sarees"},{"title":"Tissue Sarees"},{"title":"Satin Sarees"},{"title":"Velvet Sarees"},{"title":"Jute Sarees"},{"title":"Brasso Sarees"},{"title":"Shimmer Sarees"},{"title":"Brocade Sarees"},{"title":"Jacquard Sarees"},{"title":"Dupion Sarees"},{"title":"Saree Blouses"},{"title":"Sarees Combo"}]},{"title":"by type","menu_items":[{"title":"Supernet Sarees"},{"title":"Banarasi Sarees"},{"title":"Banarasi Silk Sarees"},{"title":"Kalamkari Sarees"},{"title":"Chanderi Sarees"},{"title":"Tussar Silk Sarees"},{"title":"Organza Sarees"},{"title":"Wedding Sarees"},{"title":"Printed Sarees"},{"title":"Lehenga Sarees"},{"title":"Bhagalpuri Silk Sarees"},{"title":"Heavy Work Sarees"},{"title":"Party Wear Sarees"},{"title":"Traditional Sarees"},{"title":"One Minute Sarees"},{"title":"Kerala Sarees"},{"title":"Bandhani Sarees"},{"title":"Ikat Sarees"},{"title":"Hand Woven Sarees"}]},{"title":"bollywood sarees","menu_items":[{"title":"Kareena Kapoor Sarees"},{"title":"Katrina Kaif Saree"},{"title":"Madhuri Dixit Sarees"},{"title":"Deepika Padukone Saree"},{"title":"Priyanka Chopra Saree"},{"title":"Sridevi Sarees"},{"title":"Anushka Sharma Saree"},{"title":"Shilpa Shetty Sarees"},{"title":"Sonakshi Sinha Saree"},{"title":"Bipasha Basu Sarees"},{"title":"Aishwarya Rai Saree"},{"title":"Sonam Kapoor Saree"},{"title":"Vidya Balan Saree"}]}]},{"title":"Salwar Kameez","menu_columns":[{"title":"","menu_items":[{"title":"Dress Materials"},{"title":"Anarkali Salwar Kameez"},{"title":"Cotton Salwar Kameez"},{"title":"Party Wear Salwar Kameez"},{"title":"Pakistani"},{"title":"Wedding"},{"title":"Salwars \u0026 Churidars"},{"title":"Semi Stitched Salwar Suits"},{"title":"Bollywood Salwars"},{"title":"Salwar Combo"}]}]},{"title":"More","menu_columns":[{"title":"bridal","menu_items":[{"title":"Bridal Sets"},{"title":"Bridal Lehengas"},{"title":"Bridal Sarees"}]},{"title":"lehengas","menu_items":[{"title":"Ghagra Choli"},{"title":"Lehenga Choli"},{"title":"Bollywood Lehengas"}]},{"title":"bags","menu_items":[{"title":"Hand Bags"},{"title":"Clutches"},{"title":"Wallets"},{"title":"Tote Bags"},{"title":"Backpacks"},{"title":"Sling Bags"},{"title":"Potli Bags"}]},{"title":"other apparel","menu_items":[{"title":"Kurtas \u0026 Kurtis"},{"title":"Tops"},{"title":"Stoles \u0026 Dupattas"},{"title":"Tunics"},{"title":"Leggings"},{"title":"Shawls"},{"title":"Dresses"},{"title":"Skirts"}]}]},{"title":"Home Decor","menu_columns":[{"title":"accessories","menu_items":[{"title":"Wall Decals"},{"title":"Wall Clocks"},{"title":"Ipad Covers"},{"title":"Laptop Skins"},{"title":"Phone Cases"},{"title":"Candles"},{"title":"Flowers"},{"title":"Artificial Flowers"},{"title":"Table Lamps"},{"title":"Trays"},{"title":"Vases"},{"title":"Wall Art"},{"title":"Tea Kettle"},{"title":"Paintings"},{"title":"Stationery"},{"title":"Photo Frames"},{"title":"Decorative Plates"},{"title":"Pots"},{"title":"Sculptures"},{"title":"Other"}]},{"title":"furnishing","menu_items":[{"title":"Pillow Covers"},{"title":"Bed Sheets"},{"title":"Duvet Covers"},{"title":"Quilts"},{"title":"Table Cloth"},{"title":"Table Mats \u0026 Runner"},{"title":"Carpets"},{"title":"Jaipuri Razai"},{"title":"Other"}]}]},{"title":"Gifts","menu_columns":[{"title":"by recipients","menu_items":[{"title":"For Him"},{"title":"For Her"},{"title":"For Kids"},{"title":"For Dad"},{"title":"For Mom"},{"title":"For Husband"},{"title":"For Wife"},{"title":"For Boyfriend"},{"title":"For Girlfriend"},{"title":"For Brother"},{"title":"For Sister"}]},{"title":"by occasions","menu_items":[{"title":"Birthday"},{"title":"Engagement"},{"title":"Wedding"},{"title":"Anniversary"},{"title":"Congratulation"},{"title":"House Warming"},{"title":"Office Opening"}]},{"title":"by festivals","menu_items":[{"title":"Christmas Gifts"},{"title":"Christmas Decorations"},{"title":"Valentine Gifts"},{"title":"Ganesh Chaturthi"},{"title":"Rakhi Online"},{"title":"New Year"},{"title":"Teachers Day"},{"title":"Engineers Day"},{"title":"Thanksgiving"},{"title":"Onam gifts"},{"title":"Navratri lehenga Chaniya Choli"},{"title":"Diwali Gifts"}]}]},{"title":"Lehenga","menu_columns":[]}]}

我想节省手动编写与如此复杂的 JSON 相对应的 Java 对象(模型)的时间。

是否有任何工具可以帮助将这种复杂的 JSON 快速转换为 java 模型?

我查看了http://www.jsonschema2pojo.org/但我认为它没有生成正确的 Java POJO。我不是在寻找将 JSON 转换为 java 对象的库(如 GSON、Jackson),而是寻找用于生成 java 模型类的在线工具。

最佳答案

我编写了一个简单的 JavaScript 工具来自动生成 java 类文件。它仅适用于 Chrome 浏览器。这是链接:

http://www.karvitech.com/Json2Java.html

关于java - 快速将复杂的json转换为java对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31244915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com