Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

simdjson: Can I get the string value from a double field? #1802

Answered by lemire
Jack012a asked this question in Q&A
Discussion options

#include <iostream>

#include "simdjson.h"

using namespace simdjson;
using namespace std;

int main(void) {
  std::string json = R "(  { "
  foo ": 1.20 }  )";
  dom::parser parser;
  dom::object object;
  auto error = parser.parse(json).get(object);
  if (error) {
    cerr << error << endl;
    return -1;
  }
  for (dom::key_value_pair field: object) {
    cout << field.key << " = " << field.value << endl;
  }

  return 0;
}

$ ./build/quickstart
foo = 1.2

Question> Is there a way that I can retrieve the std::string of 1.20 through this parser?

Thank you

You must be logged in to vote

Replies: 1 comment

Comment options

https://github.com/simdjson/simdjson/blob/master/doc/basics.md#direct-access-to-the-raw-string

You must be logged in to vote
0 replies
Answer selected by Jack012a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.