WFCCJsonSerializer.m 756 B

123456789101112131415161718192021222324252627
  1. //
  2. // WFCCJsonSerializer.m
  3. // WFChatClient
  4. //
  5. // Created by Rain on 2022/5/31.
  6. // Copyright © 2022 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCCJsonSerializer.h"
  9. @implementation WFCCJsonSerializer
  10. - (id)toJsonObj {
  11. return [[NSMutableDictionary alloc] init];
  12. }
  13. - (void)setDict:(NSMutableDictionary *)dict key:(NSString *)key longlongValue:(long long)longlongValue {
  14. if (longlongValue > 9007199254740991LL) {
  15. dict[key] = [NSString stringWithFormat:@"%lld", longlongValue];
  16. } else {
  17. dict[key] = @(longlongValue);
  18. }
  19. }
  20. - (NSString *)toJsonStr {
  21. return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:[self toJsonObj] options:kNilOptions error:nil] encoding:NSUTF8StringEncoding];
  22. }
  23. @end