Skip to content

Comment storage and formatting options #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b3613b1
retain comments; formatting options
PersonTheCat Jan 1, 2019
3ef838f
remove debug line
PersonTheCat Jan 1, 2019
66055ed
remove commented lines
PersonTheCat Jan 1, 2019
5be309a
consistency with hjson-js and potential bugs
PersonTheCat Jan 27, 2019
c9501e3
update javadocs
PersonTheCat Jan 27, 2019
4139b97
appease the Travis-CI gods
PersonTheCat Jan 27, 2019
91654a2
just playing around, at this point
PersonTheCat Jan 27, 2019
72e4292
fix ML string comment bug
PersonTheCat Jan 28, 2019
57424ee
Gate new comments feature behind outputComments flag
dqsully Feb 9, 2019
f7fa38d
Disable bracesSameLine by default
dqsully Feb 9, 2019
1b5ec5f
fix line length differences between versions
PersonTheCat Feb 19, 2019
e9d7404
adjust array BOL position
PersonTheCat Feb 19, 2019
a9e34f3
literals are no longer singletons
PersonTheCat Feb 24, 2019
42b6b48
container formatting
PersonTheCat Feb 25, 2019
90cd3cd
allow array lines to begin with commas
PersonTheCat Feb 25, 2019
2c12671
Important new formatting.
PersonTheCat Feb 25, 2019
799ba74
Fixed some ML spaces; Update tests
PersonTheCat Feb 25, 2019
27f5880
better code reuse and clarity
PersonTheCat Feb 26, 2019
e1c724c
add unit test for comments
PersonTheCat Feb 27, 2019
acadc24
Add JsonObject#has
PersonTheCat Jun 18, 2019
cc6e9e3
Unsafe functions
PersonTheCat Aug 29, 2019
75dd824
Merge branch 'master' of https://github.com/PersonTheCat/hjson-java
PersonTheCat Aug 29, 2019
23ae01e
More unsafe functions
PersonTheCat Aug 29, 2019
f5aa8d7
Better yet
PersonTheCat Aug 29, 2019
fb20872
Fix missing JsonObject#has
PersonTheCat Aug 29, 2019
62ea94b
Fix raw cast error
PersonTheCat Aug 30, 2019
f379e8d
Revert "Fix raw cast error"
PersonTheCat Aug 30, 2019
e091986
Fix raw cast error
PersonTheCat Aug 30, 2019
ae16c84
Temporary Project Structure
PersonTheCat Jun 20, 2020
df33c58
Value Usage Tracking
PersonTheCat Jun 22, 2020
d93f21f
Bump Jitpack
PersonTheCat Jun 22, 2020
6eed3f3
Revert Project Structure Changes
PersonTheCat Jun 22, 2020
8ae93ad
Update Version Number
PersonTheCat Jun 22, 2020
4ff0749
Fix legacy bug; new tests
PersonTheCat Aug 3, 2020
f5cde7a
Update README.md
PersonTheCat Jul 8, 2021
3f041f6
Merge changes from Cave Generator
PersonTheCat Jul 9, 2021
04d7dd8
Safer new line configuration
PersonTheCat Aug 25, 2021
5356d7f
Bump version
PersonTheCat Aug 25, 2021
6368ec3
Better raw conversions
PersonTheCat Oct 5, 2021
58abb66
JsonValue#copyComments and JsonValue#clearComments
PersonTheCat Nov 13, 2021
1bc0294
Bump version to C5
PersonTheCat Nov 13, 2021
465fe44
Bump tag version
PersonTheCat Feb 6, 2022
e4f7489
Expose indexOf and get by index
PersonTheCat Feb 6, 2022
c67c6e6
Expose JsonLiteral
PersonTheCat Feb 6, 2022
8765432
Expose JsonValue#formatComment
PersonTheCat Feb 6, 2022
2823fc5
New utilities for comment manipulation
PersonTheCat Feb 7, 2022
addbc28
JsonArray#indexOf and #lastIndexOf
PersonTheCat Feb 7, 2022
5742b30
JsonValue#deepCopy and #shallowCopy
PersonTheCat Feb 7, 2022
9dcad46
Better equals and hash implementations
PersonTheCat Feb 7, 2022
654de79
Test cases for deep and shallow copy
PersonTheCat Feb 7, 2022
8d4a6eb
Only append comment if comment is not empty
PersonTheCat Feb 7, 2022
0a635c8
Bump tag version
PersonTheCat Feb 7, 2022
5220e4d
Bump tag version
PersonTheCat Feb 7, 2022
face1b5
A few new test cases and bugs fixed
PersonTheCat Feb 8, 2022
eca87a6
JsonObject and JsonArray#getAllPaths
PersonTheCat Feb 8, 2022
9665341
Bump tag version
PersonTheCat Feb 8, 2022
bbe91b0
Bump tag version
PersonTheCat Feb 11, 2022
4e0e504
JsonValue#prependComment and variants
PersonTheCat Feb 11, 2022
2b9f788
Better copying of JSON metadata
PersonTheCat Feb 11, 2022
4d161ed
Minor fixes for JsonValue#valueOf
PersonTheCat Feb 11, 2022
b280a2b
Better multiline block comment formatter
PersonTheCat Feb 11, 2022
93f1305
Bump tag version
PersonTheCat Feb 12, 2022
68d48ea
Fix comment position
PersonTheCat Feb 12, 2022
a3eb6c3
Notice of deprecation
PersonTheCat Mar 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ gradle
gradlew
gradle.bat
build/
out/
hjson.iml
.idea
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# hjson-java
# PersonTheCat/hjson-java

## Notice of deprecation

This repository is being replaced with a new ecosystem: [XJS](https://github.com/exjson). The new ecosystem will primarily focus on its own syntax and data storage format, but will provide compatibility with Hjson, YAML, JSON-C, and other formats through `xjs-compat`. It is also built from the ground up to support streams, type coercion, and provides a number of other utilities which I believe will make for an extremely convenient experience. If your code is based on this fork of Hjson, I recommend migrating as soon as possible.

# hjson-java

[![Build Status](https://img.shields.io/travis/hjson/hjson-java.svg?style=flat-square)](http://travis-ci.org/hjson/hjson-java)
[![Maven Central](https://img.shields.io/maven-central/v/org.hjson/hjson.svg?style=flat-square)](http://search.maven.org/#search|ga|1|g%3A%22org.hjson%22%20a%3A%22hjson%22)
[![Javadoc](https://javadoc-emblem.rhcloud.com/doc/org.hjson/hjson/badge.svg?style=flat-square&color=blue)](http://www.javadoc.io/doc/org.hjson/hjson)
Expand Down
74 changes: 74 additions & 0 deletions assets/comments1_result.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Headers placed in this location will now be
# correctly saved by hjson-java!
{
# Comments can be placed above values.
numPenguins: 417 # And beside values.
// Multiple comment styles are supported.
anotherNum: 24
randString: "info" # Even with quotes and commas.
/*
There's a lot of info here.
Here's another line.
And another line.
*/
complicatedObject:
{
apples: 12
bananas: 14
/*
a fancy
interior comment
for you
*/
}
# Objects and arrays placed on a single line are
# considered "condensed" and will remain that way.
arrayOfNums: [ 1, 2, 3, 4, 5 ]
# Objects and arrays with multiple values per-
# line will continue to have multiple values
# per-line, based on the average line length.
multiLine:
[
1, 2, 3
4, 5, 6
]
# These should get averaged to 2.
averageLines:
[
1, 2
3, 4
5, 6
]
# This works especially well for multi-dimensional
# arrays (i.e. matrices).
matrix:
[
[ 1, 2, 3 ]
[ 4, 5, 6 ]
[ 7, 8, 9 ]
/*
Another comment
goes here
*/
]
# Objects will do the same. Keys and values will
# be correctly quoted, when necessary.
multiLineObj:
{
value1: 1, value2: 2
value3: "three", value4: 4
}
# Unnecessary quotes will be removed.
unnecessaryQuotes:
{
numPenguins: 36
numPolarBears: twenty-four
}
# Just to verify that these still work.
multiLineString:
'''
test
and more test
and still more
'''
}
67 changes: 67 additions & 0 deletions assets/comments1_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"numPenguins": 417,
"anotherNum": 24,
"randString": "info",
"complicatedObject":
{
"apples": 12,
"bananas": 14
},
"arrayOfNums":
[
1,
2,
3,
4,
5
],
"multiLine":
[
1,
2,
3,
4,
5,
6
],
"averageLines":
[
1,
2,
3,
4,
5,
6
],
"matrix":
[
[
1,
2,
3
],
[
4,
5,
6
],
[
7,
8,
9
]
],
"multiLineObj":
{
"value1": 1,
"value2": 2,
"value3": "three",
"value4": 4
},
"unnecessaryQuotes":
{
"numPenguins": 36,
"numPolarBears": "twenty-four"
},
"multiLineString": "test\nand more test\nand still more"
}
74 changes: 74 additions & 0 deletions assets/comments1_test.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Headers placed in this location will now be
# correctly saved by hjson-java!
{
# Comments can be placed above values.
numPenguins: 417 # And beside values.
// Multiple comment styles are supported.
anotherNum: 24
randString: "info", # Even with quotes and commas.
/*
There's a lot of info here.
Here's another line.
And another line.
*/
complicatedObject:
{
apples: 12
bananas: 14
/*
a fancy
interior comment
for you
*/
}
# Objects and arrays placed on a single line are
# considered "condensed" and will remain that way.
arrayOfNums: [ 1, 2, 3, 4, 5 ]
# Objects and arrays with multiple values per-
# line will continue to have multiple values
# per-line, based on the average line length.
multiLine:
[
1, 2, 3
4, 5, 6
]
# These should get averaged to 2.
averageLines:
[
1
2, 3
4, 5, 6
]
# This works especially well for multi-dimensional
# arrays (i.e. matrices).
matrix:
[
[ 1, 2, 3 ]
[ 4, 5, 6 ]
[ 7, 8, 9 ]
/*
Another comment
goes here
*/
]
# Objects will do the same. Keys and values will
# be correctly quoted, when necessary.
multiLineObj:
{
value1: 1, value2: 2
value3: "three", value4: 4
}
# Unnecessary quotes will be removed.
unnecessaryQuotes:
{
"numPenguins": 36,
"numPolarBears": "twenty-four"
}
# Just to verify that these still work.
multiLineString:
'''
test
and more test
and still more
'''
}
9 changes: 9 additions & 0 deletions assets/legacy_result.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
num: 55
dec: 55.5
obj:
{
value: 55
}
array: [ 55 ]
}
12 changes: 12 additions & 0 deletions assets/legacy_result.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"num": 55,
"dec": 55.5,
"obj":
{
"value": 55
},
"array":
[
55
]
}
7 changes: 7 additions & 0 deletions assets/legacy_test.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
num: 55
dec: 55.5
obj:
{
value: 55
}
array: [ 55 ]
2 changes: 1 addition & 1 deletion assets/mltabs_result.hjson
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
foo:
foo:
'''
bar joe
oki doki
Expand Down
27 changes: 4 additions & 23 deletions assets/pass1_result.hjson
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[
JSON Test Pattern pass1
{
"object with 1 member":
[
array with 1 element
]
}
{ "object with 1 member": [ "array with 1 element" ] }
{}
[]
-42
Expand Down Expand Up @@ -42,24 +37,10 @@
"# -- --> */": " "
" s p a c e d ":
[
1
2
3
4
5
6
7
]
compact:
[
1
2
3
4
5
6
7
1, 2, 3
4, 5, 6
]
compact: [ 1, 2, 3, 4, 5, 6 ]
jsontext: '''{"object with 1 member":["array with 1 element"]}'''
quotes: " " %22 0x22 034 "
"/\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?": A key can be any string
Expand Down
6 changes: 2 additions & 4 deletions assets/pass1_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@
3,
4,
5,
6,
7
6
],
"compact": [
1,
2,
3,
4,
5,
6,
7
6
],
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
"quotes": "&#34; \" %22 0x22 034 &#x22;",
Expand Down
4 changes: 2 additions & 2 deletions assets/pass1_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
"# -- --> */": " ",
" s p a c e d " :[1,2 , 3

,
,

4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7],
4 , 5 , 6 ,],"compact":[1,2,3,4,5,6],
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
"quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
Expand Down
40 changes: 1 addition & 39 deletions assets/pass2_result.hjson
Original file line number Diff line number Diff line change
@@ -1,39 +1 @@
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
[
Not too deep
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
]
[ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ "Not too deep" ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading