json-simple

exceeding LONG.MAX_VALUE in JSON Simple parser

≡放荡痞女 提交于 2019-12-14 02:48:14
问题 I am currently using the JSON Simple library for parsing JSON in my application. I have run into an issue while parsing that is throwing the following error: java.lang.NumberFormatException: For input string: "107701583138930170002" I have narrowed this down to what I believe is the issue, the number is to big to be a LONG type. The problem is that I do not have control over this number otherwise I would make it a string. Is there a way to make JSON Simple parse this into a BigInt instead of

Create JSON file with deep array

半世苍凉 提交于 2019-12-12 00:28:23
问题 I need to create new json file with the following structre I am not able to success since i have structure inside structure/array ,the file should look like : any idea how to create one like this? { "Entry1": [ { "id": "0001", "type": "USER", }, { "id": "0002", "type": "EMP", "property":"Salery", } ], "Entry2": [ { "id": "0005", "name": "Vacation", "property":"user", }, { "id": "0008", "name": "Work", } ] } I was tried to use the following code without success. JSONObject obj = new JSONObject

Parsing decimal numbers, some of which lack a decimal separator, in JSON data using JSON-Simple (Java)

会有一股神秘感。 提交于 2019-12-11 08:17:06
问题 I am trying to use the JSON-Simple JSON processor library. When parsing JSON fragment such as: "speed":1.13 …I call get and cast as a Double . No problem. Double speed = ( Double ) wind.get( "speed" ); But then I encounter a value without a decimal fraction. Ex: 1 rather than 1.0 . "speed":1 Granted, the publisher of this data should have written "speed":1.0 . But they did not. My get with casting throws an exception: Exception in thread "main" java.lang.ClassCastException: class java.lang

How to write a JSONObject to a file, which has JSONArray inside it, in Java?

别说谁变了你拦得住时间么 提交于 2019-12-11 02:57:01
问题 I have JSON file, that I need to read, edit and write out again. Reading works fine, I struggle with the write part of the JSON Array in my data. I use JSON.simple library to work with JSON in Java. The file looks like this: { "maxUsers":100, "maxTextLength":2000, "maxFileSize":2000, "services": [ { "serviceName":"Яндекc", "className":"YandexConnector.class", "isEnabled":true }, { "serviceName":"Google", "className":"GoogleConnector.class", "isEnabled":false } ] } When I try to write JSON

How to parse a JSON File without root element using org.json.simple?

淺唱寂寞╮ 提交于 2019-12-11 02:05:55
问题 I want to parse json file "c:/employeesRecord.json" using org.json.simple library. Below is sample json data, each record is sperated by next line in the file. {"Employees ":["A ;B ;C ;D ;E ;F"],"JobTitle":"Software Engineer"} {"Employees ":["A ;B ;C ;D ;E ;F"],"JobTitle":"Software Engineer"} {"Employees ":["A ;B ;C ;D ;E ;F"],"JobTitle":"Software Engineer"} ... How to parse such json file without root element using org.json.simple. 回答1: You can "tweak" the input from the file and change it

Gradle dependency json-simple error

心已入冬 提交于 2019-12-10 14:53:23
问题 I'm fairly new to Gradle so I'm trying to build a Java project and not sure about the dependencies. I have never gotten Gradle configured to be able to do my tests or now a jar file to compile and run. My build.gradle : apply plugin: 'java' apply plugin: 'maven' repositories { jcenter() } dependencies { compile 'org.slf4j:slf4j-api:1.7.25' compile 'org.json:json:20160212' testCompile 'junit:junit:4.12' } And this is what I get on the console stating that it doesn't see my import: error:

Using Java to decode JSON array of objects

谁说胖子不能爱 提交于 2019-12-06 10:25:55
问题 I have JSON as follows: [{"0":"1","id":"1","1":"abc","name":"abc"},{"0":"2","id":"2","1":"xyz","name":"xyz"}] It is an array of objects. I need to parse it using Java. I am using the library at : http://code.google.com/p/json-simple/downloads/list Example 1 at this link approximates what I require: http://code.google.com/p/json-simple/wiki/DecodingExamples I have the following code: /** Decode JSON */ // Assuming the JSON string is stored in jsonResult (String) Object obj = JSONValue.parse

JSON: “Unexpected character (<) at position 0”

自闭症网瘾萝莉.ら 提交于 2019-12-06 05:32:56
Here's the twitch.tv api request to get channel summary: http://api.justin.tv/api/streams/summary.json?channel=mychannel . If I post it via browser, I get correct results. But programmatically I receive an exception during result parsing. I use apache HttpClient to send requests and receive responses. And JSON-Simple to parse JSON content. This is how I try to get JSON from response according to api: HttpClient httpClient = HttpClients.createDefault(); HttpGet getRequest = new HttpGet(new URL("http://api.justin.tv/api/streams/summary.json?channel=mychannel").toURI()); getRequest.addHeader(

JSON.simple API Javadoc

无人久伴 提交于 2019-12-05 11:51:50
问题 Is there a Javadoc for JSON.simple? 回答1: I generated the Javadoc from source and put it online. The project wiki has some interesting pages and version 1.0.2 also had an interesting README. 来源: https://stackoverflow.com/questions/2640309/json-simple-api-javadoc