Giter Site home page Giter Site logo

Comments (3)

tangqiaoboy avatar tangqiaoboy commented on June 9, 2024

你是问如何把 NSDictionary 转成 NSString的 JSON 吗?

from ytknetwork.

jbasttdi avatar jbasttdi commented on June 9, 2024

谢谢回复,我是有这样的类结构:

@interface A : Entity
@Property(strong,nonatomic) NSString* _id;
@Property(strong,nonatomic) NSString* title;
@Property(strong,nonatomic) SyncEntity *syncEntity;

@interface SyncEntity:NSObject
@Property(strong,nonatomic) NSString* synctitle;
@Property(strong,nonatomic) NSString* comments;

@interface Entity:NSObject
@Property(strong,nonatomic) NSString* entityKey;
@Property(strong,nonatomic) NSString* entityValue;

调用:
A *a=[[A alloc]init];
a._id=@"id";
a.title=@"title";
a.syncEntity=[[SyncEntity alloc]init];
a.syncEntity.synctitle=@"synctitle";
a.syncEntity.comments=@"comments";
a.entityKey=@"entityKey";
a.entityValue=@"entityValue";'

我想能获取这个jsonString字符串,我用了一些NSDictionary 转NSString 的方法,总是报错:
Invalid type in JSON write (SyncEntity)
实在搞不懂了,所以还想请您帮看看,是不是mantle在model转json字符串这块没这个功能呢?我用了JSONModel是可以实现这个转换的。
非常感谢!

from ytknetwork.

jbasttdi avatar jbasttdi commented on June 9, 2024

算了,我改用JSONModel吧。

from ytknetwork.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.