Skip to content

Commit

Permalink
Make entities public
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishanMMT committed Jul 1, 2023
1 parent d3619fc commit 9446541
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
28 changes: 13 additions & 15 deletions Sources/JSONViewer/JSONNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,41 @@

import Foundation

enum JSONNodeType {
public enum JSONNodeType {
case object
case array
case other
}

var str = "".jsonNode

struct JSONNode: Identifiable, Hashable, Sequence {
public struct JSONNode: Identifiable, Hashable, Sequence {

static func == (lhs: JSONNode, rhs: JSONNode) -> Bool {
public static func == (lhs: JSONNode, rhs: JSONNode) -> Bool {
return lhs.id == rhs.id
}

func hash(into hasher: inout Hasher) {
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}

init(key: String, value: String, children: [JSONNode]) {
public init(key: String, value: String, children: [JSONNode]) {
self.key = key
self.value = value
self.children = children
}

let id = UUID()
var key: String
let value: String
var children: [JSONNode]
var type: JSONNodeType = .other
public let id = UUID()
public var key: String
public let value: String
public var children: [JSONNode]
public var type: JSONNodeType = .other

var isExpandable: Bool {
public var isExpandable: Bool {
return !children.isEmpty
}

typealias Iterator = Array<JSONNode>.Iterator
public typealias Iterator = Array<JSONNode>.Iterator

func makeIterator() -> Iterator {
public func makeIterator() -> Iterator {
return children.makeIterator()
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/JSONViewer/JSONNodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import SwiftUI

struct JSONNodeView: View {
public struct JSONNodeView: View {
var node: JSONNode
var level: Int
@State var expanded: [String: Bool]
var body: some View {
public var body: some View {
VStack {
if node.isExpandable {
VStack(alignment: .trailing) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/JSONViewer/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

extension String {
public extension String {
var jsonNode: JSONNode? {
if let jsonData = self.data(using: .utf8) {
do {
Expand Down

0 comments on commit 9446541

Please sign in to comment.