Skip to content

Commit

Permalink
Switched to use kjson-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pwall567 committed Jul 3, 2024
1 parent 746a850 commit 7281963
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 60 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [8.1] - 2024-07-03
### Changed
- `JSONTypeException`, `ParseException`, `pom.xml`: switched to use `kjson-exception`
### Removed
- `JSONException`

## [8.0] - 2024-07-01
### Changed
- `pom.xml`, `deploy.yml`: tidied up following conversion to GitHub Actions
- `build.xml`, `deploy.yml`: tidied up following conversion to GitHub Actions
- `pom.xml`: updated Kotlin version to 1.9.24
- `JSONInt`, `JSONLong`, `JSONDecimal`: modify for deprecation in Kotlin 1.9.x
(These would not normally be breaking changes, but the major version should have been updated for version 7.4 because
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ The exception also includes a property `key` (of type `Any?`) which is used to p
the error, for example a [`JSONPointer`](https://github.com/pwall567/kjson-pointer) or a property name.
When the key is provided, it will be appended to the message, as "`, at {key}`".

Starting from version 8.1 of this library, `JSONException` has been extracted to a separate library –
[`kjson-exception`](https://github.com/pwall567/kjson-exception) – so that it may be included in other projects
independent from this library

### `JSONTypeException`

A common error case arises when a `JSONValue` is found to be of the wrong type, for example, when a `JSONArray` is
Expand Down Expand Up @@ -653,25 +657,25 @@ The diagram was produced by [Dia](https://wiki.gnome.org/Apps/Dia/); the diagram

## Dependency Specification

The latest version of the library is 8.0, and it may be obtained from the Maven Central repository.
The latest version of the library is 8.1, and it may be obtained from the Maven Central repository.

### Maven
```xml
<dependency>
<groupId>io.kjson</groupId>
<artifactId>kjson-core</artifactId>
<version>8.0</version>
<version>8.1</version>
</dependency>
```
### Gradle
```groovy
implementation "io.kjson:kjson-core:8.0"
implementation "io.kjson:kjson-core:8.1"
```
### Gradle (kts)
```kotlin
implementation("io.kjson:kjson-core:8.0")
implementation("io.kjson:kjson-core:8.1")
```

Peter Wall

2024-07-01
2024-07-03
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>kjson-core</artifactId>
<version>8.0</version>
<version>8.1</version>
<name>JSON Kotlin core functionality</name>
<description>JSON Kotlin core functionality</description>
<packaging>jar</packaging>
Expand Down Expand Up @@ -60,6 +60,11 @@
</pluginRepositories>

<dependencies>
<dependency>
<groupId>io.kjson</groupId>
<artifactId>kjson-exception</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>net.pwall.json</groupId>
<artifactId>json-functions</artifactId>
Expand Down
50 changes: 0 additions & 50 deletions src/main/kotlin/io/kjson/JSONException.kt

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/kotlin/io/kjson/JSONTypeException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class JSONTypeException(
val nodeName: String = "Node",
val target: String,
val value: JSONValue?,
val key: Any? = null,
key: Any? = null,
) : JSONException("$nodeName not correct type ($target), was ${value.displayValue()}", key)
12 changes: 10 additions & 2 deletions src/main/kotlin/io/kjson/parser/ParseException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @(#) ParseException.kt
*
* kjson-core JSON Kotlin core functionality
* Copyright (c) 2021 Peter Wall
* Copyright (c) 2021, 2024 Peter Wall
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -33,4 +33,12 @@ import io.kjson.parser.ParserConstants.rootPointer
*
* @author Peter Wall
*/
class ParseException(val text: String, val pointer: String = rootPointer) : JSONException(text, pointer)
class ParseException(
text: String,
override val key: String = rootPointer,
) : JSONException(text, key) {

val pointer: String
get() = key

}
1 change: 1 addition & 0 deletions src/main/kotlin/io/kjson/parser/ParserConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import io.kjson.util.LookupSet
@Suppress("unused")
object ParserConstants {

@Suppress("ConstPropertyName")
const val rootPointer = ""
const val BOM = '\uFEFF'
const val MAX_INTEGER_DIGITS_LENGTH = 10
Expand Down

0 comments on commit 7281963

Please sign in to comment.