Transform JSON to Ndjson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 07:32 AM
Hi,
I am getting JSON from my SQL Server - Select snap I want to convert it into NDJSON to push the data into ElasticSearch
example:-
the data from SQL server:
[
{
“Id”: “1”,
“Type”: “student”,
“Name”: “s one”,
“Age”: 27
},
{
“Id”: “2”,
“Type”: “teacher”,
“Name”: “t one”,
“Age”: 40
},
{
“Id”: “3”,
“Type”: “student”,
“Name”: “s two”,
“Age”: 16
},
{
“Id”: “4”,
“Type”: “teacher”,
“Name”: “t two”,
“Age”: 27
}
]
Format which ElasticSearch accept
{ “index” : { “_index”: “schoolindex”} }
{“Id”:“1”,“Type”:“student”,“Name”:“s one”,“Age”:27}
{ “index” : { “_index”: “schoolindex”} }
{“Id”:“2”,“Type”:“teacher”,“Name”:“t one”,“Age”:40}
{ “index” : { “_index”: “schoolindex”} }
{“Id”:“3”,“Type”:“student”,“Name”:“s two”,“Age”:16}
{ “index” : { “_index”: “schoolindex”} }
{“Id”:“4”,“Type”:“teacher”,“Name”:“t two”,“Age”:27}
which will be the best way to achieve the required format?
Any help will be greatly appreciated
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 12:05 AM
Hi @iambiswa25,
Please try this pipeline to get the desired o/p.
Pipeline:
JSON-to_NdJSON.slp (6.2 KB)
Let me know if it works.
Cheers 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 07:08 AM
Hi Thanks for your response
I’ve done that without using Script
uploading here if anyone need
json to ndjson_2023_06_19.slp (7.9 KB)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 11:19 AM
Great solution,
I assumed that you need them as separate documents, not as a string.
Thanks for sharing 🙂