Skip to content

Instantly share code, notes, and snippets.

@AndyGaskell
Created December 12, 2019 10:26
Show Gist options
  • Save AndyGaskell/35312228aa05173ccaeb306ba3a774f2 to your computer and use it in GitHub Desktop.
Save AndyGaskell/35312228aa05173ccaeb306ba3a774f2 to your computer and use it in GitHub Desktop.
// To parse this JSON data, do
//
// final config = configFromJson(jsonString);
import 'dart:convert';
Config configFromJson(String str) => Config.fromJson(json.decode(str));
String configToJson(Config data) => json.encode(data.toJson());
class Config {
bool success;
String message;
dynamic messages;
Data data;
Config({
this.success,
this.message,
this.messages,
this.data,
});
factory Config.fromJson(Map<String, dynamic> json) => Config(
success: json["success"],
message: json["message"],
messages: json["messages"],
data: Data.fromJson(json["data"]),
);
Map<String, dynamic> toJson() => {
"success": success,
"message": message,
"messages": messages,
"data": data.toJson(),
};
}
class Data {
Settings settings;
Data({
this.settings,
});
factory Data.fromJson(Map<String, dynamic> json) => Data(
settings: Settings.fromJson(json["settings"]),
);
Map<String, dynamic> toJson() => {
"settings": settings.toJson(),
};
}
class Settings {
Filters notifications;
List<Channel> channels;
Filters filters;
Sharing sharing;
Features features;
Feeds feeds;
Tagline tagline;
Settings({
this.notifications,
this.channels,
this.filters,
this.sharing,
this.features,
this.feeds,
this.tagline,
});
factory Settings.fromJson(Map<String, dynamic> json) => Settings(
notifications: Filters.fromJson(json["notifications"]),
channels: List<Channel>.from(json["channels"].map((x) => Channel.fromJson(x))),
filters: Filters.fromJson(json["filters"]),
sharing: Sharing.fromJson(json["sharing"]),
features: Features.fromJson(json["features"]),
feeds: Feeds.fromJson(json["feeds"]),
tagline: Tagline.fromJson(json["tagline"]),
);
Map<String, dynamic> toJson() => {
"notifications": notifications.toJson(),
"channels": List<dynamic>.from(channels.map((x) => x.toJson())),
"filters": filters.toJson(),
"sharing": sharing.toJson(),
"features": features.toJson(),
"feeds": feeds.toJson(),
"tagline": tagline.toJson(),
};
}
class Channel {
String title;
String description;
String channel;
Channel({
this.title,
this.description,
this.channel,
});
factory Channel.fromJson(Map<String, dynamic> json) => Channel(
title: json["title"],
description: json["description"],
channel: json["channel"],
);
Map<String, dynamic> toJson() => {
"title": title,
"description": description,
"channel": channel,
};
}
class Features {
IdAuth idAuth;
Premium premium;
Features({
this.idAuth,
this.premium,
});
factory Features.fromJson(Map<String, dynamic> json) => Features(
idAuth: IdAuth.fromJson(json["id_auth"]),
premium: Premium.fromJson(json["premium"]),
);
Map<String, dynamic> toJson() => {
"id_auth": idAuth.toJson(),
"premium": premium.toJson(),
};
}
class IdAuth {
bool enabled;
String status;
bool userRegistered;
IdAuth({
this.enabled,
this.status,
this.userRegistered,
});
factory IdAuth.fromJson(Map<String, dynamic> json) => IdAuth(
enabled: json["enabled"],
status: json["status"],
userRegistered: json["user_registered"],
);
Map<String, dynamic> toJson() => {
"enabled": enabled,
"status": status,
"user_registered": userRegistered,
};
}
class Premium {
bool enabled;
Premium({
this.enabled,
});
factory Premium.fromJson(Map<String, dynamic> json) => Premium(
enabled: json["enabled"],
);
Map<String, dynamic> toJson() => {
"enabled": enabled,
};
}
class Feeds {
int news;
int events;
Feeds({
this.news,
this.events,
});
factory Feeds.fromJson(Map<String, dynamic> json) => Feeds(
news: json["news"],
events: json["events"],
);
Map<String, dynamic> toJson() => {
"news": news,
"events": events,
};
}
class Filters {
String title;
String description;
bool online;
List<Tag> tags;
Filters({
this.title,
this.description,
this.online,
this.tags,
});
factory Filters.fromJson(Map<String, dynamic> json) => Filters(
title: json["title"],
description: json["description"],
online: json["online"],
tags: json["tags"] == null ? null : List<Tag>.from(json["tags"].map((x) => Tag.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"title": title,
"description": description,
"online": online,
"tags": tags == null ? null : List<dynamic>.from(tags.map((x) => x.toJson())),
};
}
class Tag {
String title;
String description;
String tag;
Tag({
this.title,
this.description,
this.tag,
});
factory Tag.fromJson(Map<String, dynamic> json) => Tag(
title: json["title"],
description: json["description"],
tag: json["tag"],
);
Map<String, dynamic> toJson() => {
"title": title,
"description": description,
"tag": tag,
};
}
class Sharing {
bool enabled;
String prefix;
List<String> ignore;
Sharing({
this.enabled,
this.prefix,
this.ignore,
});
factory Sharing.fromJson(Map<String, dynamic> json) => Sharing(
enabled: json["enabled"],
prefix: json["prefix"],
ignore: List<String>.from(json["ignore"].map((x) => x)),
);
Map<String, dynamic> toJson() => {
"enabled": enabled,
"prefix": prefix,
"ignore": List<dynamic>.from(ignore.map((x) => x)),
};
}
class Tagline {
String title;
Tagline({
this.title,
});
factory Tagline.fromJson(Map<String, dynamic> json) => Tagline(
title: json["title"],
);
Map<String, dynamic> toJson() => {
"title": title,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment