typ0520 / jsontodartclass Goto Github PK
View Code? Open in Web Editor NEW🚀Plugin for Android Studio And IntelliJ Idea to generate dart class code from JSON text ( Json to Dart )
License: GNU General Public License v3.0
🚀Plugin for Android Studio And IntelliJ Idea to generate dart class code from JSON text ( Json to Dart )
License: GNU General Public License v3.0
如果$valueGetter != null 但是$valueGetter也不是一个List,$valueGetter as List会抛异常的。应该改为:$valueGetter is List。
KotlineDataClass.kt 的第64行。
修改前:
p.isListType() && !p.getGenericType().isPrimitiveType() -> { append("$valueGetter != null ? ($valueGetter as List).map((i) => ${p.getGenericType()}.fromJson(i)).toList() : null") }
修改后:
p.isListType() && !p.getGenericType().isPrimitiveType() -> { append("$valueGetter is List ? ($valueGetter as List).map((i) => ${p.getGenericType()}.fromJson(i)).toList() : null") }
Plugin 'com.github.typ0520.jsontodart' failed to initialize and will be disabled. Please restart Android Studio.
java.io.FileNotFoundException: /Users/tong/Desktop/idea.txt (Arquivo ou diretório inexistente)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.(FileOutputStream.java:213)
at kotlin.io.FilesKt__FileReadWriteKt.appendBytes(FileReadWrite.kt:91)
at kotlin.io.FilesKt__FileReadWriteKt.appendText(FileReadWrite.kt:118)
at kotlin.io.FilesKt__FileReadWriteKt.appendText$default(FileReadWrite.kt:118)
at wu.seal.jsontodart.utils.LogUtil.i(LogUtil.kt:19)
at wu.seal.jsontodart.JsonToKotlinApplication.initComponent(JsonToKotlinApplication.kt:15)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:486)
at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:104)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$createComponents$9(ApplicationImpl.java:447)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:164)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:582)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:532)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:87)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:151)
at com.intellij.openapi.application.impl.ApplicationImpl.createComponents(ApplicationImpl.java:471)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:88)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:405)
at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:391)
at com.intellij.idea.IdeaApplication.run(IdeaApplication.java:217)
at com.intellij.idea.IdeaApplication.lambda$initApplication$0(IdeaApplication.java:77)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
这段json无法生成bean,是什么原因呢?
{ "onsale": { "num": "11", "list": [ { "frame_tags": [ "" ], "layout": "0室0厅0卫", "frame_image": { "image_url": "http://img.ljcdn.com/110000-frame/04ffd65b-01bc-4b8b-ac62-f3ac99634bde5.jpg", "ext_name": "jpg" }, "frame_name": "linkframe", "building_area": "建面0", "price": "价格待定", "onsale_num": "未知", "sell_status": "在售", "update_state": "2020.5.1更新" } ] }, "saleout": { "num": "11", "list": [ { "frame_tags": [ "" ], "layout": "0室0厅0卫", "frame_image": { "image_url": "http://img.ljcdn.com/110000-frame/04ffd65b-01bc-4b8b-ac62-f3ac99634bde5.jpg", "ext_name": "jpg" }, "frame_name": "linkframe", "building_area": "建面0", "price": "价格待定", "onsale_num": "未知", "sell_status": "在售", "update_state": "2020.5.1更新" } ] }, "presale": { "num": "11", "list": [ { "frame_tags": [ "" ], "layout": "0室0厅0卫", "frame_image": { "image_url": "http://img.ljcdn.com/110000-frame/04ffd65b-01bc-4b8b-ac62-f3ac99634bde5.jpg", "ext_name": "jpg" }, "frame_name": "linkframe", "building_area": "建面0", "price": "价格待定", "onsale_num": "未知", "sell_status": "在售", "update_state": "2020.5.1更新" } ] } }
If a JSON has an uppercase field for example
{
TestField: ""
}
it will generate dart code with
testField
which doesn't match with JSON and throws error while mapping.
RT. android studio 4.0
https://plugins.jetbrains.com/plugin/12562-jsontodart just like this we need single file clas option in settings!
If a field in JSON is null, the corresponding Object type will be generated, and Object.fromJSON will issue an error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.