Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • DSS /

For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

avatar image
Question by filip.balas · Sep 14, 2016 at 03:51 AM · dss-rest-apidssdatascope-selectjavajsonjar

org.json.JSONOrderedObject Java library

Hi,

First of all, this is my first JSON in Java experience.

I was getting 400 - bad request for extraction call (/Extractions/Extract). Then I've tried to sent just a json string with property order exactly as it was in the example and it was working. A bit tricky.

I don't think my library (com.googlecode.json-simple) can maintain the property order within a JSONObject. In the API's Java examples there's a org.json.JSONOrderedObject - I was not able to find out which JSON library contains this class.

Thanks for any advice.

Filip

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

4 Replies

  • Sort: 
avatar image
Best Answer
Answer by filip.balas · Sep 15, 2016 at 05:33 AM

Ok, now I see these classes are included within the examples.

Anyway I was hoping for more "Maven" way - I don't feel comfortable neither including this 3rd party to my source code nor creating and deploying artifact from those.

I've resolved the issue with this simple work-around, still using json-simple, but substituting standard HashMap with LinkedHashMap.

public class JSONOrderedObject extends LinkedHashMap<String, Object> implements Map<String, Object>, JSONAware, JSONStreamAware {
                

@Overridepublic String toJSONString() {
return JSONObject.toJSONString(this);}

@Overridepublic void writeJSONString(Writer writer) throws IOException {
JSONObject.writeJSONString(this, writer);}
}
Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
simone.guerrieri · Sep 30, 2021 at 07:12 PM 0
Share

I have the same problem: I would like use something more "Maven".

I found org.springframework.boot.configurationprocessor.json.JSONObject which internally uses a LinkedHashMap.

maven dependency:

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-configuration-processor</artifactId>

<version>2.3.12.RELEASE</version>


However I was wondering if anyone else is using something different and why.

avatar image
REFINITIV
Answer by Christiaan Meihsl · Sep 14, 2016 at 04:07 AM

@filip.balas

If you download the Java code examples from the downloads tab, you will find the libraries we used, under \DSS2_Java_Examples\src\org\json.

Note these Java samples are currently being rewritten to make them easier to understand. The first one in the new style is DSS2SearchFirRICClientV2.java. The others will come soon.

Comment
Troy Dalldorf

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Christiaan Meihsl ♦♦ · Sep 19, 2016 at 03:28 AM 0
Share

Sample rewrite is finished, the new versions are now available for download here.

avatar image
REFINITIV
Answer by pimchaya.wongrukun01 · Sep 14, 2016 at 04:15 AM

Based on JSONOrderedObject source code, it seem that the class is written using pure java classes(no using any JSON library classs) as shown below:


import.png (19.3 KiB)
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by susana.chang · Sep 15, 2016 at 02:46 PM

@filip.balas

Thanks for sharing your work around solution. That's great! The org.json.JSONOrderedObject class is a modified version of the org.json.JSONObject, to help maintain the order of the properties in the JSON request object (yes, as you noted, the exact order of the properties is required for most of the requests). The main difference is the org.json.JSONOrderedObject class uses LinkedHashMap instead on Map.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
8 People are following this question.

Related Questions

Java Code Examples not working | java.net.UnknownHostException

Request timeouts

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

running the same http request that was valid - getting error - could not sent request

How to use CorporateActions extractions

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges